the socket server creates request handler (using the class it was givento handle each request our custom requesthandler class provides method for each kind of request it can handleplus the handle(method that it must have since that is the only method used by the socket server but before looking at the methods we will look at the class declaration and the class' class variables class requesthandler(socketserver streamrequesthandler)carslock threading lock(calllock threading lock(call dictget_car_details=lambda self*argsself get_car_details(*args))change_mileage=lambda self*argsself change_mileage(*args))change_owner=lambda self*argsself change_owner(*args))new_registration=lambda self*argsself new_registration(*args))shutdown=lambda self*argsself shutdown(*args)we have created socketserver streamrequesthandler subclass since we are using streaming (tcpserver corresponding socketserver datagramrequesthandler is available for udp serversor we could inherit the socketserver baserequesthandler class for lower-level access the requesthandler cars dictionary is class variable that was added in the main(functionit holds all the registration data adding additional attributes to objects (such as classes and instancescan be done outside the class (in this case in the main(functionwithout formality (as long as the object has __dict__)and can be very convenient since we know that the class depends on this variable some programmers would have added cars none as class variable to document the variable' existence almost every request-handling method needs access to the cars databut we must ensure that the data is never accessed by two methods (from two different threadsat the same timeif it isthe dictionary may become corruptedor the program might crash to avoid this we have lock class variable that we will use to ensure that only one thread at time accesses the cars dictionary (threadingincluding the use of locksis covered in the call dictionary is another class variable each key is the name of an action that the server can perform and each value is function for performing the action we cannot use the methods directly as we did with the functions gil the gil (global interpreter lockensures that accesses to the cars dictionary are synchronizedbut as noted earlierwe do not take advantage of this since it is cpython implementation detail