Skip to content

Commit d6bb457

Browse files
authored
Fix incorrect usage of once flag in async Sentinel (#2718)
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).
1 parent 7fc4c76 commit d6bb457

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fix incorrect usage of once flag in async Sentinel
12
* asyncio: Fix memory leak caused by hiredis (#2693)
23
* Allow data to drain from async PythonParser when reading during a disconnect()
34
* Use asyncio.timeout() instead of async_timeout.timeout() for python >= 3.11 (#2602)

redis/asyncio/sentinel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ async def execute_command(self, *args, **kwargs):
220220
kwargs.pop("once")
221221

222222
if once:
223+
await random.choice(self.sentinels).execute_command(*args, **kwargs)
224+
else:
223225
tasks = [
224226
asyncio.Task(sentinel.execute_command(*args, **kwargs))
225227
for sentinel in self.sentinels
226228
]
227229
await asyncio.gather(*tasks)
228-
else:
229-
await random.choice(self.sentinels).execute_command(*args, **kwargs)
230230
return True
231231

232232
def __repr__(self):

0 commit comments

Comments
 (0)