dispatcher.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:dataplicity-agent 作者: wildfoundry 项目源码 文件源码
def dispatch_packet(self, packet):
        if not getattr(packet, 'no_log', False):
            self.log.debug('received %r', packet)
        packet_type = packet.type
        method = self._packet_handlers.get(packet_type, None)

        if method is None:
            self.on_missing_handler(packet)
            return None

        arg_spec = inspect.getargspec(method)
        args, kwargs = packet.get_method_args(len(arg_spec[0]))

        try:
            inspect.getcallargs(method, packet_type, *args, **kwargs)
        except TypeError as e:
            raise PacketFormatError(text_type(e))

        try:
            ret = method(packet_type, *args, **kwargs)
        except Exception:
            raise
        else:
            return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号