From 169305d2f04c318ca42e39b2924868cb619d56ae Mon Sep 17 00:00:00 2001 From: "Github Action (Release)" Date: Thu, 8 Feb 2024 20:39:32 -0500 Subject: [PATCH 1/2] Added installSignalHandlers as an argument to KiteTicker.connect() --- kiteconnect/ticker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kiteconnect/ticker.py b/kiteconnect/ticker.py index ad858d7..1010cf1 100644 --- a/kiteconnect/ticker.py +++ b/kiteconnect/ticker.py @@ -493,13 +493,14 @@ def _create_connection(self, url, **kwargs): def _user_agent(self): return (__title__ + "-python/").capitalize() + __version__ - def connect(self, threaded=False, disable_ssl_verification=False, proxy=None): + def connect(self, threaded=False, disable_ssl_verification=False, proxy=None, installSignalHandlers=True): """ Establish a websocket connection. - `threaded` is a boolean indicating if the websocket client has to be run in threaded mode or not - `disable_ssl_verification` disables building ssl context - `proxy` is a dictionary with keys `host` and `port` which denotes the proxy settings + - `installSignalHandlers` is a boolean indicating if signal handlers should be installed or not. Ignored if `threaded` is True """ # Custom headers headers = { @@ -534,6 +535,9 @@ def connect(self, threaded=False, disable_ssl_verification=False, proxy=None): self.websocket_thread.daemon = True self.websocket_thread.start() else: + if not installSignalHandlers: + opts["installSignalHandlers"] = False + reactor.run(**opts) def is_connected(self): From 2c4a87bef73416c99dca86a4421bc832c7fafe7b Mon Sep 17 00:00:00 2001 From: "Github Action (Release)" Date: Tue, 5 Mar 2024 01:28:09 -0500 Subject: [PATCH 2/2] Changed solution to daemon flag for thread --- kiteconnect/ticker.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kiteconnect/ticker.py b/kiteconnect/ticker.py index 1010cf1..72fe0c9 100644 --- a/kiteconnect/ticker.py +++ b/kiteconnect/ticker.py @@ -493,7 +493,7 @@ def _create_connection(self, url, **kwargs): def _user_agent(self): return (__title__ + "-python/").capitalize() + __version__ - def connect(self, threaded=False, disable_ssl_verification=False, proxy=None, installSignalHandlers=True): + def connect(self, threaded=False, disable_ssl_verification=False, proxy=None, daemon=True): """ Establish a websocket connection. @@ -532,12 +532,9 @@ def connect(self, threaded=False, disable_ssl_verification=False, proxy=None, in # Signals are not allowed in non main thread by twisted so suppress it. opts["installSignalHandlers"] = False self.websocket_thread = threading.Thread(target=reactor.run, kwargs=opts) - self.websocket_thread.daemon = True + self.websocket_thread.daemon = daemon self.websocket_thread.start() else: - if not installSignalHandlers: - opts["installSignalHandlers"] = False - reactor.run(**opts) def is_connected(self):