使用autbahn.asyncio.wamp非阻塞地运行几个ApplicationSession

使用autbahn.asyncio.wamp非阻塞地运行几个ApplicationSession,第1张

使用autbahn.asyncio.wamp非阻塞地运行几个ApplicationSession

按照您链接扭曲的方法,我设法通过asyncio设置 start_loop = False 来获得相同的行为 __

import asynciofrom autobahn.asyncio.wamp import ApplicationSession, ApplicationRunnerrunner1 = ApplicationRunner(url, realm, extra={'cli_id': 1})coro1 = runner1.run(MyApplicationSession, start_loop=False)runner2 = ApplicationRunner(url, realm, extra={'cli_id': 2})coro2 = runner2.run(MyApplicationSession, start_loop=False)asyncio.get_event_loop().run_until_complete(coro1)asyncio.get_event_loop().run_until_complete(coro2)asyncio.get_event_loop().run_forever()class MyApplicationSession(ApplicationSession):    def __init__(self, cfg):        super().__init__(cfg)        self.cli_id = cfg.extra['cli_id']   def onJoin(self, details):        print("session attached", self.cli_id)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5661985.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存