Open oliora opened 5 days ago
If you want to handle sigint yourself you have to disable the handling in this client:
async with socketio.AsyncSimpleClient(handle_sigint=False) as ws:
# ...
To my knowledge there is no way to have two sigint handlers installed in the same loop.
For any other signals outside of SIGINT there shouldn't be a problem, this library only provides a default SIGINT handler.
What are the consequences of not handling signals in the client?
All the default handler does is disconnect any active clients gracefully. If you use your own you will want to do this yourself.
Thank you.
Do I get the same effect if I use [async] with client
?
Ah yes, with the simple client it should when it exits the context manager block.
python-socketio library sets its own signal handler in a way that disables signals handlers that were previously set with
asyncio.loop.add_signal_handler
To Reproduce
Steps:
Waiting...
is printedReceived signal ...
Expected behavior
Received signal ...
is printed then application is stopped.If I comment line
await ws.connect(....)
then the application behavior is as expected.Additional context Aside from broken applications it is just a bad practice if library messes up with such a global thing as signal handlers. Signal handlers should be left to the application concern.