inside the try block we get the lambda function that is appropriate to the requested action we use lock to protect access to the call dictionaryalthough arguably we are being overly cautious as alwayswe do as little as possible within the scope of the lock--in this case we just do dictionary lookup to get reference to function once we have the function we call itpassing self as the first argument and the rest of the data tuple as the other arguments here we are doing function callso no self is passed by python this does not matter since we pass self in ourselvesand inside the lambda the passed-in self is used to call the method in the normal way the outcome is that the callself method(*data[ :])is madewhere method is the method corresponding to the action given in data[ if the action is to shut downa custom finish exception is raised in the shutdown(methodin which case we know that the client cannot expect replyso we just return but for any other action we pickle the result of calling the action' corresponding method (using pickle protocol version )and write the size of the pickle and then the pickled data itself def get_car_details(selflicense)with self carslockcar copy copy(self cars get(licensenone)if car is not nonereturn (truecar seatscar mileagecar ownerreturn (false"this license is not registered"this method begins by trying to acquire the car data lock--and blocks until it gets the lock it then uses the dict get(method with second argument of none to get the car with the given license--or to get none the car is immediately copied and the with statement is finished this ensures that the lock is in force for the shortest possible time although reading does not change the data being readbecause we are dealing with mutable collection it is possible that another method in another thread wants to change the dictionary at the same time as we want to read it--using lock prevents this from happening outside the scope of the lock we now have copy of the car object (or nonewhich we can deal with at our leisure without blocking any other threads like all the car registration action-handling methodswe return tuple whose first item is boolean success/failure flag and whose other items vary none of these methods has to worry or even know how its data is returned to the client beyond the "tuple with boolean first itemsince all the network interaction is encapsulated in the handle(method def change_mileage(selflicensemileage)if mileage return (false"cannot set negative mileage"with self carslockcar self cars get(licensenone