From 16fa5af3c8620b99453596f5bc3ae44fa6799937 Mon Sep 17 00:00:00 2001 From: SipanOhanyan <54571287+SipanOhanyan@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:56:37 +0400 Subject: [PATCH] Fixing problem with infinite connecting threads reconnect_interval does not seem to have any affect #102 Reconnect logic spamming logs and creating threads until resource exhaustion occurs #97 --- .../transport/websockets/websocket_transport.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/signalrcore/transport/websockets/websocket_transport.py b/signalrcore/transport/websockets/websocket_transport.py index 283d921..402f8ba 100644 --- a/signalrcore/transport/websockets/websocket_transport.py +++ b/signalrcore/transport/websockets/websocket_transport.py @@ -227,17 +227,15 @@ def handle_reconnect(self): except Exception as ex: self.logger.error(ex) sleep_time = self.reconnection_handler.next() - threading.Thread( - target=self.deferred_reconnect, - args=(sleep_time,) - ).start() + self.deferred_reconnect(sleep_time) def deferred_reconnect(self, sleep_time): time.sleep(sleep_time) try: if not self.connection_alive: - self.send(PingMessage()) + if not self.connection_checker.running: + self.send(PingMessage()) except Exception as ex: self.logger.error(ex) self.reconnection_handler.reconnecting = False - self.connection_alive = False \ No newline at end of file + self.connection_alive = False