networking the code for loading is easy because we have used context manager from the standard library' contextlib module to ensure that the file is closed irrespective of whether an exception occurs another way of achieving the same effect is to use custom context manager for exampleclass gzipmanagerdef __init__(selffilenamemode)self filename filename self mode mode def __enter__(self)self fh gzip open(self filenameself modereturn self fh def __exit__(self*ignore)self fh close(using the custom gzipmanagerthe with statement becomeswith gzipmanager(filename"rb"as fhthis context manager will work with any python version but if we only care about python or laterwe can simply writewith gzip openas fhsince from python the gzip open(function supports the context manager protocol the save(function (not shownis structurally the same as the load(functiononly we open the file in write binary modeuse pickle dump(to save the dataand don' return anything class carregistrationserver(socketserver threadingmixinsocketserver tcpserver)pass multiple inheritance this is the complete custom server class if we wanted to create server that used processes rather than threadsthe only change would be to inherit the socketserver forkingmixin class instead of the socketserver threadingmixin class the term mixin is often used to describe classes that are specifically designed to be multiply-inherited the socketserver module' classes can be used to create variety of custom servers including udp servers and unix tcp and udp serversby inheriting the appropriate pair of base classes note that the socketserver mixin class we used must always be inherited first this is to ensure that the mixin class' methods are used in preference to the second class' methods for those methods that are provided by bothsince python looks for methods in the base classes in the order in which the base classes are specifiedand uses the first suitable method it finds