Skip to content

Commit

Permalink
Prevent multiple tasks for reconnection (#1369)
Browse files Browse the repository at this point in the history
* Prevent multiple taks for reconnection

As discussed here.

#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 <humayun.ajmal@strikeready.com>

* async client

---------

Signed-off-by: Humayun Ajmal <humayun.ajmal@strikeready.com>
Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
  • Loading branch information
humayunsr and miguelgrinberg authored Dec 14, 2024
1 parent 78d1124 commit b6ee33e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/socketio/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,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)

Expand Down
2 changes: 1 addition & 1 deletion src/socketio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,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)

Expand Down

0 comments on commit b6ee33e

Please sign in to comment.