我希望能够从现有的事件循环/反应器中派生出一个独立的事件循环/反应器。假设我在一个模块standaloneapps
中有一个应用程序:
#in standaloneapps.py
class StandaloneApp(ApplicationSession):
def runner(self, message):
print(message)
@inlineCallbacks
def start_app(self):
yield self.subscribe(self.runner, 'com.example.some_topic')
我希望能够从不同的应用程序启动此应用程序。示例:
from standaloneapps import StandaloneApp
class ApplicationStarter(ApplicationSession):
@inlineCallbacks
def onJoin(self, details):
yield self.subscribe(self.start_app, 'com.example.startapp')
def start_app(self, message):
print('subscribing to app')
new_runner = ApplicationRunner(url="ws://127.0.0.1:8080/ws",
realm="realm1")
runner.run(StandaloneApp)
我可以启动ApplicationStarter
,但一旦发布事件'com.example.startapp'
,crossbar就会崩溃,出现异常builtins.Exception: not joined
。你知道吗
也许这看起来是一个过于复杂的设置,但我正在尝试让一个应用程序订阅一个“app dispatcher”,它动态地启动新的应用程序,这些应用程序可能提前知道,也可能不知道。我希望新的应用程序在不同的事件循环上运行,以便保持隔离。你知道吗
编辑:只需添加: 跑步者。跑步(StandaloneApp,启动反应堆=假)
调用启动第二个应用程序。这迫使它在同一个循环中运行。你知道吗
相关问题 更多 >
编程相关推荐