Skip to content

Commit

Permalink
Fix incorrect usage of once flag in async Sentinel (#2718)
Browse files Browse the repository at this point in the history
In the execute_command of the async Sentinel, the once flag was being
used incorrectly, with its meaning inverted. To fix we just needed to invert
the if and else bodies. This isn't being caught by the tests currently
because the tests of commands that use this flag do not check their
results/effects (for example the "test_ckquorum" test).
  • Loading branch information
felipou committed Apr 27, 2023
1 parent 7fc4c76 commit d6bb457
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Fix incorrect usage of once flag in async Sentinel
* asyncio: Fix memory leak caused by hiredis (#2693)
* Allow data to drain from async PythonParser when reading during a disconnect()
* Use asyncio.timeout() instead of async_timeout.timeout() for python >= 3.11 (#2602)
Expand Down
4 changes: 2 additions & 2 deletions redis/asyncio/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ async def execute_command(self, *args, **kwargs):
kwargs.pop("once")

if once:
await random.choice(self.sentinels).execute_command(*args, **kwargs)
else:
tasks = [
asyncio.Task(sentinel.execute_command(*args, **kwargs))
for sentinel in self.sentinels
]
await asyncio.gather(*tasks)
else:
await random.choice(self.sentinels).execute_command(*args, **kwargs)
return True

def __repr__(self):
Expand Down

0 comments on commit d6bb457

Please sign in to comment.