wamp_client.py 文件源码

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

项目:django-wamp-client 作者: fcurella 项目源码 文件源码
def forward_procedure(self, func_path, uri, options=None):
        @inlineCallbacks
        def wrapped(*args, **kwargs):
            reply_channel_name = self.channel_layer.new_channel('{}?'.format(uri))
            payload = {
                'func_path': func_path,
                'uri': uri,
                'args': args,
                'kwargs': kwargs,
                'reply_channel': reply_channel_name,
            }
            channel = Channel('wamp.events')
            channel.send(payload)

            d = Deferred()

            def cleanup(result):
                self.channels.remove(reply_channel_name)
                del self.reply_channels[reply_channel_name]
                self.log.info('result: {}'.format(result['total']))
            d.addCallback(cleanup)
            self.channels.add(reply_channel_name)
            self.reply_channels[reply_channel_name] = d

            yield d
        self.log.info("registered procedure for '{}'".format(uri))
        if options is None:
            options = types.RegisterOptions()
        return self.register(wrapped, uri, options=options)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号