diff options
author | Guillaume Tassery <tassery.guillaume@gmail.com> | 2022-12-25 14:25:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-25 15:25:59 +0200 |
commit | 1000a2b3c04570e6d011a6dcad2ec5299ff00563 (patch) | |
tree | d0e87d4ce16ea1bf6d18dead3b455c186c40ed03 | |
parent | f06f3db647c81bc24fa9bdad33822ca6175c32eb (diff) | |
download | redis-py-1000a2b3c04570e6d011a6dcad2ec5299ff00563.tar.gz |
Add `timeout` parameter for SentinelManagedConnection (#2495)
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | redis/asyncio/sentinel.py | 13 |
2 files changed, 11 insertions, 3 deletions
@@ -1,3 +1,4 @@ + * Add `timeout=None` in `SentinelConnectionManager.read_response` * Documentation fix: password protected socket connection (#2374) * Allow `timeout=None` in `PubSub.get_message()` to wait forever * add `nowait` flag to `asyncio.Connection.disconnect()` diff --git a/redis/asyncio/sentinel.py b/redis/asyncio/sentinel.py index 99c5074..ec17886 100644 --- a/redis/asyncio/sentinel.py +++ b/redis/asyncio/sentinel.py @@ -1,7 +1,7 @@ import asyncio import random import weakref -from typing import AsyncIterator, Iterable, Mapping, Sequence, Tuple, Type +from typing import AsyncIterator, Iterable, Mapping, Optional, Sequence, Tuple, Type from redis.asyncio.client import Redis from redis.asyncio.connection import ( @@ -63,9 +63,16 @@ class SentinelManagedConnection(Connection): lambda error: asyncio.sleep(0), ) - async def read_response(self, disable_decoding: bool = False): + async def read_response( + self, + disable_decoding: bool = False, + timeout: Optional[float] = None, + ): try: - return await super().read_response(disable_decoding=disable_decoding) + return await super().read_response( + disable_decoding=disable_decoding, + timeout=timeout, + ) except ReadOnlyError: if self.connection_pool.is_master: # When talking to a master, a ReadOnlyError when likely |