def handle_request(self, msg):
        """Dispatch a request message to the appropriate method.

        Parameters
        ----------
        msg : Message object
            The request message to dispatch.

        """
        method = self.__class__.unhandled_request
        if msg.name in self._request_handlers:
            method = self._request_handlers[msg.name]

        try:
            reply = method(self, msg)
            if isinstance(reply, Message):
                # If it is a message object, assume it is a reply.
                reply.mid = msg.mid
                assert (reply.mtype == Message.REPLY)
                assert (reply.name == msg.name)
                self._logger.info("%s OK" % (msg.name,))
                self.send_message(reply)
            else:
                # Just pass on what is, potentially, a future. The implementor
                # of the request handler method must arrange for a reply to be
                # sent. Since clients have no business dealing with requests in
                # any case we don't do much to help them.
                return reply
        # We do want to catch everything that inherits from Exception
        # pylint: disable-msg = W0703
        except Exception:
            e_type, e_value, trace = sys.exc_info()
            reason = "\n".join(traceback.format_exception(
                e_type, e_value, trace, self._tb_limit))
            self._logger.error("Request %s FAIL: %s" % (msg.name, reason))
def handle_request ( self , msg ) : method = self . __class__ . unhandled_request if msg . name in self . _request_handlers : method = self . _request_handlers [ msg . name ] try : reply = method ( self , msg ) if isinstance ( reply , Message ) : reply . mid = msg . mid assert ( reply . mtype == Message . REPLY ) assert ( reply . name == msg . name ) self . _logger . info ( "%s OK" % ( msg . name , ) ) self . send_message ( reply ) else : return reply except Exception : e_type , e_value , trace = sys . exc_info ( ) reason = "\n" . join ( traceback . format_exception ( e_type , e_value , trace , self . _tb_limit ) ) self . _logger . error ( "Request %s FAIL: %s" % ( msg . name , reason ) )
Dispatch a request message to the appropriate method.

        Parameters
        ----------
        msg : Message object
            The request message to dispatch.