diff --git a/src/socketio/async_client.py b/src/socketio/async_client.py index 0d85aa1..fb1abc1 100644 --- a/src/socketio/async_client.py +++ b/src/socketio/async_client.py @@ -581,7 +581,7 @@ class AsyncClient(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) diff --git a/src/socketio/client.py b/src/socketio/client.py index 00d7961..c4f9eaa 100644 --- a/src/socketio/client.py +++ b/src/socketio/client.py @@ -539,7 +539,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)