Skip to content

Commit 56b254e

Browse files
aniodvora-h
andauthored
Save a reference to created async tasks, to avoid tasks potentially disappearing (#2816)
* save a reference to created tasks, to avoid tasks disappearing mid-execution * Ignore linter * Ignore linter --------- Co-authored-by: dvora-h <[email protected]>
1 parent 1b370da commit 56b254e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

redis/asyncio/cluster.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1135,13 +1135,13 @@ def set_nodes(
11351135
if remove_old:
11361136
for name in list(old.keys()):
11371137
if name not in new:
1138-
asyncio.create_task(old.pop(name).disconnect())
1138+
task = asyncio.create_task(old.pop(name).disconnect()) # noqa
11391139

11401140
for name, node in new.items():
11411141
if name in old:
11421142
if old[name] is node:
11431143
continue
1144-
asyncio.create_task(old[name].disconnect())
1144+
task = asyncio.create_task(old[name].disconnect()) # noqa
11451145
old[name] = node
11461146

11471147
def _update_moved_slots(self) -> None:

0 commit comments

Comments
 (0)