Skip to content

Commit

Permalink
async_cluster: properly remove old nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshgupta137 committed May 26, 2022
1 parent af3597d commit ca09cb9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,18 +902,16 @@ def set_nodes(
new: Dict[str, "ClusterNode"],
remove_old: bool = False,
) -> None:
tasks = []
if remove_old:
tasks = [
asyncio.ensure_future(node.disconnect())
for name, node in old.items()
if name not in new
]
for name in list(old.keys()):
if name not in new:
asyncio.ensure_future(old.pop(name).disconnect())

for name, node in new.items():
if name in old:
if old[name] is node:
continue
tasks.append(asyncio.ensure_future(old[name].disconnect()))
asyncio.ensure_future(old[name].disconnect())
old[name] = node

def _update_moved_slots(self) -> None:
Expand Down

0 comments on commit ca09cb9

Please sign in to comment.