def handle_client(afd): global proto proto = Proto(afd) cur_dir[current_thread()] = os.getcwd() while True: resp_b = proto.recv() if resp_b == "": print "Client disconnected" return resp = msgpack.unpackb(resp_b) COMMANDS[resp['type']](resp['data'])