@@ -68,6 +68,11 @@ class Client(object):
6868 packets. Custom json modules must have ``dumps`` and ``loads``
6969 functions that are compatible with the standard library
7070 versions.
71+ :param handle_sigint: Set to ``True`` to automatically handle disconnection
72+ when the process is interrupted, or to ``False`` to
73+ leave interrupt handling to the calling application.
74+ Interrupt handling can only be enabled when the
75+ client instance is created in the main thread.
7176
7277 The Engine.IO configuration supports the following settings:
7378
@@ -90,9 +95,9 @@ class Client(object):
9095 def __init__ (self , reconnection = True , reconnection_attempts = 0 ,
9196 reconnection_delay = 1 , reconnection_delay_max = 5 ,
9297 randomization_factor = 0.5 , logger = False , serializer = 'default' ,
93- json = None , ** kwargs ):
98+ json = None , handle_sigint = True , ** kwargs ):
9499 global original_signal_handler
95- if original_signal_handler is None and \
100+ if handle_sigint and original_signal_handler is None and \
96101 threading .current_thread () == threading .main_thread ():
97102 original_signal_handler = signal .signal (signal .SIGINT ,
98103 signal_handler )
@@ -101,8 +106,10 @@ def __init__(self, reconnection=True, reconnection_attempts=0,
101106 self .reconnection_delay = reconnection_delay
102107 self .reconnection_delay_max = reconnection_delay_max
103108 self .randomization_factor = randomization_factor
109+ self .handle_sigint = handle_sigint
104110
105111 engineio_options = kwargs
112+ engineio_options ['handle_sigint' ] = handle_sigint
106113 engineio_logger = engineio_options .pop ('engineio_logger' , None )
107114 if engineio_logger is not None :
108115 engineio_options ['logger' ] = engineio_logger
0 commit comments