|
1 | 1 | import random |
2 | | -import signal |
3 | | -import threading |
4 | 2 |
|
5 | 3 | import engineio |
6 | 4 |
|
|
9 | 7 | from . import packet |
10 | 8 |
|
11 | 9 |
|
12 | | -def signal_handler(sig, frame): # pragma: no cover |
13 | | - """SIGINT handler. |
14 | | -
|
15 | | - Notify any clients that are in a reconnect loop to abort. Other |
16 | | - disconnection tasks are handled at the engine.io level. |
17 | | - """ |
18 | | - for client in base_client.reconnecting_clients[:]: |
19 | | - client._reconnect_abort.set() |
20 | | - if callable(original_signal_handler): |
21 | | - return original_signal_handler(sig, frame) |
22 | | - else: # pragma: no cover |
23 | | - # Handle case where no original SIGINT handler was present. |
24 | | - return signal.default_int_handler(sig, frame) |
25 | | - |
26 | | - |
27 | | -original_signal_handler = None |
28 | | - |
29 | | - |
30 | 10 | class Client(base_client.BaseClient): |
31 | 11 | """A Socket.IO client. |
32 | 12 |
|
@@ -87,24 +67,6 @@ class Client(base_client.BaseClient): |
87 | 67 | fatal errors are logged even when |
88 | 68 | ``engineio_logger`` is ``False``. |
89 | 69 | """ |
90 | | - def __init__(self, reconnection=True, reconnection_attempts=0, |
91 | | - reconnection_delay=1, reconnection_delay_max=5, |
92 | | - randomization_factor=0.5, logger=False, serializer='default', |
93 | | - json=None, handle_sigint=True, **kwargs): |
94 | | - global original_signal_handler |
95 | | - if handle_sigint and original_signal_handler is None and \ |
96 | | - threading.current_thread() == threading.main_thread(): |
97 | | - original_signal_handler = signal.signal(signal.SIGINT, |
98 | | - signal_handler) |
99 | | - |
100 | | - super().__init__(reconnection=reconnection, |
101 | | - reconnection_attempts=reconnection_attempts, |
102 | | - reconnection_delay=reconnection_delay, |
103 | | - reconnection_delay_max=reconnection_delay_max, |
104 | | - randomization_factor=randomization_factor, |
105 | | - logger=logger, serializer=serializer, json=json, |
106 | | - handle_sigint=handle_sigint, **kwargs) |
107 | | - |
108 | 70 | def connect(self, url, headers={}, auth=None, transports=None, |
109 | 71 | namespaces=None, socketio_path='socket.io', wait=True, |
110 | 72 | wait_timeout=1): |
|
0 commit comments