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)
评论列表
文章目录