Skip to content

Commit

Permalink
Fixing problem with infinite connecting threads
Browse files Browse the repository at this point in the history
reconnect_interval does not seem to have any affect mandrewcito#102
Reconnect logic spamming logs and creating threads until resource exhaustion occurs mandrewcito#97
  • Loading branch information
SipanOhanyan authored Nov 13, 2024
1 parent bc4ade2 commit 16fa5af
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions signalrcore/transport/websockets/websocket_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
self.connection_alive = False

0 comments on commit 16fa5af

Please sign in to comment.