I'd like to be able to spawn an independent event loop/reactor from an existing one. Let's say I have an application in a module 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')
I'd like to be able to start this application from a different one. Example:
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)
I can start ApplicationStarter
, but as soon as I publish the event 'com.example.startapp'
crossbar crashes with exception builtins.Exception: not joined
.
Perhaps this seems like an overly complicated setup, but I'm trying to have one application subscribe to an 'app dispatcher' which dynamically starts new applications which may-or-may-not be known ahead of time. I'd like for the new applications to be running on different event loops so as to stay isolated.