summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Machado <462154+felipou@users.noreply.github.com>2023-04-27 11:17:17 -0300
committerGitHub <noreply@github.com>2023-04-27 17:17:17 +0300
commitd6bb4573618672d525c84877ec69827ff975299f (patch)
tree3370e150820edc03877634be7cf4396acf7d1520
parent7fc4c76c778163c21d396f99dcc710d99942895f (diff)
downloadredis-py-d6bb4573618672d525c84877ec69827ff975299f.tar.gz
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).
-rw-r--r--CHANGES1
-rw-r--r--redis/asyncio/sentinel.py4
2 files changed, 3 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 429045f..d1e4b2a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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)
diff --git a/redis/asyncio/sentinel.py b/redis/asyncio/sentinel.py
index ec17886..c3c0f91 100644
--- a/redis/asyncio/sentinel.py
+++ b/redis/asyncio/sentinel.py
@@ -220,13 +220,13 @@ class Sentinel(AsyncSentinelCommands):
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):