Closed maurerle closed 2 weeks ago
@rcschrg I did not find a decent way to make both - the doctests, as well as my test run without errors.
It makes sense though to be able to register an agent to the container without the existance of the async context, so it would be cool to have this
Eventually it is necessary to defer the creation of the inbox task right before the on_setup function?
I agree that this feature would be useful, I will check after I am finished with my current feature
It would be possible to work around with invisible testcode blocks (for some reason testsetup does not work, I don't know why). However, this would require to use asyncio.get_event_loop().run_until_complete instead of asyncio.run, because asyncio.run will create a new loop, but as the old loop is referenced in mango internally it crashes.
So, I think moving the inbox task creation is a good solution here. I will close the PR and propose one myself
Before, we received the error "no running event loop" when attaching an agent outside of an async context.
We solve this by assigning an event loop to all container types, making it possible to create agents in a sync setting where no event loop is running (yet). The solution is to attach the inbox task to a precreated asyncio.loop which is used later on.
Eventually, there is a smarter way to do this. Evenetually we should let the MQTT server have a second loop which is independent of ours?
(Note: this PR goes into feature-topology for now for better readability)