From 5da3e3bd06888430f518afc8e2c2cfc0be55193a Mon Sep 17 00:00:00 2001 From: Humayun Ajmal Date: Tue, 6 Aug 2024 12:16:33 +0500 Subject: [PATCH 1/2] 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 d7af4070..1b09ef6b 100644 --- a/src/socketio/client.py +++ b/src/socketio/client.py @@ -534,7 +534,7 @@ def _handle_eio_disconnect(self): 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) From 5a17a83f36c8d1da4ea635ab6656770c514fca93 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 14 Dec 2024 10:31:50 +0000 Subject: [PATCH 2/2] async client --- src/socketio/async_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socketio/async_client.py b/src/socketio/async_client.py index 5fd8daaf..f3a6b845 100644 --- a/src/socketio/async_client.py +++ b/src/socketio/async_client.py @@ -578,7 +578,7 @@ async def _handle_eio_disconnect(self): 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)