Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[events][windows] add signal handler on windows platform to properly … #344

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gazu/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@
from .exception import AuthFailedException
from .client import default_client, get_event_host
from gazu.client import make_auth_header
from engineio.base_client import signal_handler
import socketio
import os
import inspect
import signal
import socketio

if os.name == "nt":
from win32api import SetConsoleCtrlHandler

def WindowsSignalHandler(event):
if event == 0:
try:
signal_handler(signal.SIGINT, inspect.currentframe())
except:
# SetConsoleCtrlHandler handle cannot raise exceptions
pass

SetConsoleCtrlHandler(WindowsSignalHandler, 1)


class EventsNamespace(socketio.ClientNamespace):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install_requires =
python-socketio[client]>=5.11.0,<6; python_version != '2.7'
requests>=2.25.1
Deprecated==1.2.14
pywin32>=308; sys_platform == 'win32' and python_version != '2.7'

[options.packages.find]
# ignore gazutest directory
Expand Down
Loading