diff --git a/CHANGES b/CHANGES index 429045f9a5..d1e4b2aa75 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 ec17886fc6..c3c0f91545 100644 --- a/redis/asyncio/sentinel.py +++ b/redis/asyncio/sentinel.py @@ -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):