python-socketio: KeyboardInterrupt ignored on Windows
Hello, with the sample below after hitting Ctrl+C, the script exits on Linux but nothing happens on Windows.
Linux
python 3.8.6
python-engineio 3.13.2
python-socketio 4.6.0
Windows
python 3.8.5/3.9.0 neither is working
python-engineio 3.13.2
python-socketio 4.6.0
import socketio
sio = socketio.Client(logger=True, engineio_logger=True)
nspc = "/example"
@sio.event(namespace=nspc)
def connect():
print("Connected.")
@sio.event(namespace=nspc)
def disconnect():
print("Disconnected.")
sio.connect("https://example.com", namespaces=[nspc], transports="websocket")
sio.wait()
The connect event handler gets invoked, the PING/PONG starts and I attempt Ctrl+C with no success on Windows.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
Example code to handle
Ctrl+cusingwin32api.SetConsoleCtrlHandler(installpywin32first or usectypes).Hello, i have the same problem
I currently have a NodeJS server, with python as client when i connect to the server i can’t close the connection which make me close the whole terminal and re-open with venv again …
Okay, I’ll revert the fix, since clearly the previous solution is better.