按照您链接扭曲的方法,我设法通过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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)