miguelgrinberg / python-socketio

Python Socket.IO server and client
MIT License
3.96k stars 587 forks source link

option for KeyboardInterrupt to not cause disconnect #1060

Closed TodAmon closed 9 months ago

TodAmon commented 1 year ago

It appears that I cannot write an application that does its own thing with KeyboardInterrupt, as the underlying engineio client interprets this as a disconnect. There is no option when creating a client to tell it to ignore KeyboardInterrupt. Thoughts?

miguelgrinberg commented 1 year ago

You can pass handle_sigint=False and then you are free to do what you want using a custom interrupt handler. Did you see that in the docs?

TodAmon commented 1 year ago

Sorry, I tried it but must have missed something, maybe I'm on an older version. I saw it was an option for engineio

(Pdb) socketio.Client(handle_sigint=False)
*** TypeError: __init__() got an unexpected keyword argument 'handle_sigint'
miguelgrinberg commented 1 year ago

Yes, you must be on older code. I see it in the Client class in this repo here.