I am evaluating the new component based Python API.
There is one thing I cannot find a proper solution for: Reliably and cleanly termination.
I see three cases right now:
Terminating at random time when a session is open
Terminating at random time without open session
Terminating in on_leave when detecting that reconnecting does not make sense.
Case 1) seems relatively easy.
Cleanup whatever needs to be cleaned up and then call session.leave().
Open question: How to handle the case where one wants to leave the session but execute some coroutines later on for cleanup?
Case 2 and 3)
I do not see a way to stop the running component from reconnecting apart from calling asyncio.get_event_loop().stop().
That is no real solution though.
To illustrate the cases I attach a short program showing the cases.
It either tries to terminate when authentication failed or it terminates after 10 seconds.
Depending on the state of the connection this can trigger all cases above.
Has anyone an idea how to handle these cases?
One can pass a ‘main’ method to the component. It will only terminate once this method is done.
The only problem: The method is bound to a joined session. Does not seem to help in my case.
Binding the component to a constantly running methos (like the run method in the sample code) would maybe help.
termination_test.py (2.41 KB)