diff options
author | Felipe Machado <462154+felipou@users.noreply.github.com> | 2023-04-27 11:17:17 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 17:17:17 +0300 |
commit | d6bb4573618672d525c84877ec69827ff975299f (patch) | |
tree | 3370e150820edc03877634be7cf4396acf7d1520 | |
parent | 7fc4c76c778163c21d396f99dcc710d99942895f (diff) | |
download | redis-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-- | CHANGES | 1 | ||||
-rw-r--r-- | redis/asyncio/sentinel.py | 4 |
2 files changed, 3 insertions, 2 deletions
@@ -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): |