Skip to content

Commit

Permalink
Save a reference to created async tasks, to avoid tasks potentially d…
Browse files Browse the repository at this point in the history
…isappearing (#2816)

* save a reference to created tasks, to avoid tasks disappearing mid-execution

* Ignore linter

* Ignore linter

---------

Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
  • Loading branch information
anio and dvora-h committed Sep 21, 2023
1 parent 1b370da commit 56b254e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,13 +1135,13 @@ def set_nodes(
if remove_old:
for name in list(old.keys()):
if name not in new:
asyncio.create_task(old.pop(name).disconnect())
task = asyncio.create_task(old.pop(name).disconnect()) # noqa

for name, node in new.items():
if name in old:
if old[name] is node:
continue
asyncio.create_task(old[name].disconnect())
task = asyncio.create_task(old[name].disconnect()) # noqa
old[name] = node

def _update_moved_slots(self) -> None:
Expand Down

0 comments on commit 56b254e

Please sign in to comment.