I need to run a WAMP client component within a webserver (FastAPI).
All examples use the ‘run’ method to launch the component. However the run method will monopolize the event-loop as it is going to call ‘loop.run_forever’.
So currently I’m calling the ‘_run’ underneath directly from within a task but is that the proper way of doing it?
You’re using the
Component API, right? In that case, there is the
start() method, which is intended for your use-case. The
run() method starts logging,
start()s all the components, handles cleanup, etc … so if you’re already handling all that, the
start() method should be the right approach.
However I tried the below for instance and I get an error in
aio.py:473> attached to a different loop
from autobahn.asyncio.component import Component
async def amain():
def joined(session, details):
comp = Component(transports='ws://mydomain.net/crossbario/ws')
fut = comp.start()
if __name__ == '__main__':
Seems that the issue I reported above is solved by putting the import statements inside the
This should fix the loop problems: https://github.com/crossbario/txaio/pull/163
Will be in the next release.