From 5da3e3bd06888430f518afc8e2c2cfc0be55193a Mon Sep 17 00:00:00 2001 From: Humayun Ajmal Date: Tue, 6 Aug 2024 12:16:33 +0500 Subject: [PATCH] Prevent multiple taks for reconnection As discussed here. https://github.com/miguelgrinberg/python-socketio/discussions/1367 In certain scenarios, this library creates multiple reconnection tasks. A check is added to make sure that reconnection task starts only when this task is not running. Signed-off-by: Humayun Ajmal --- src/socketio/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socketio/client.py b/src/socketio/client.py index d7af407..1b09ef6 100644 --- a/src/socketio/client.py +++ b/src/socketio/client.py @@ -534,7 +534,7 @@ class Client(base_client.BaseClient): self.callbacks = {} self._binary_packet = None self.sid = None - if will_reconnect: + if will_reconnect and not self._reconnect_task: self._reconnect_task = self.start_background_task( self._handle_reconnect)