def _controller(self):
        """Return the server controller."""
        def server_controller(cmd_id, cmd_body, _):
            """Server controler."""
            if not self.init_logginig:
                # the reason put the codes here is because we cannot get
                # kvstore.rank earlier
                head = '%(asctime)-15s Server[' + str(
                    self.kvstore.rank) + '] %(message)s'
                logging.basicConfig(level=logging.DEBUG, format=head)
                self.init_logginig = True

            if cmd_id == 0:
                try:
                    optimizer = pickle.loads(cmd_body)
                except:
                    raise
                self.kvstore.set_optimizer(optimizer)
            else:
                print("server %d, unknown command (%d, %s)" % (
                    self.kvstore.rank, cmd_id, cmd_body))
        return server_controller
def _controller ( self ) : def server_controller ( cmd_id , cmd_body , _ ) : if not self . init_logginig : head = '%(asctime)-15s Server[' + str ( self . kvstore . rank ) + '] %(message)s' logging . basicConfig ( level = logging . DEBUG , format = head ) self . init_logginig = True if cmd_id == 0 : try : optimizer = pickle . loads ( cmd_body ) except : raise self . kvstore . set_optimizer ( optimizer ) else : print ( "server %d, unknown command (%d, %s)" % ( self . kvstore . rank , cmd_id , cmd_body ) ) return server_controller
Return the server controller.