Client Auto Disconnects on KeyboardInterrupt #791
-
I have a code emits audio packages in a separate thread via socketio. I use try catch KeyboardInterrupt to stop listening for audio and emits all the data left in the queue. However socketio client disconnects before data left in the queue being emitted. I think KeyboardInterrupt cause socketio client to auto disconnect How can I avoid that or how can I assign a callback to disconnect call? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes, this is correct. The Socket.IO client installs an interrupt handler, which disconnects. There is currently no option to turn this feature off, but seems this can be useful sometimes so I'll look into that. |
Beta Was this translation helpful? Give feedback.
-
This is a workaround if anyone have the same issue except KeyboardInterrupt:
# keyboard interrup cause an auto-disconnect on sio client.
# wait for sio client to reconnect
sio.connect('http://localhost:5000')
while not sio.connected:
time.sleep(0.5)
# rest of your code |
Beta Was this translation helpful? Give feedback.
Yes, this is correct. The Socket.IO client installs an interrupt handler, which disconnects. There is currently no option to turn this feature off, but seems this can be useful sometimes so I'll look into that.