From 1000a2b3c04570e6d011a6dcad2ec5299ff00563 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Sun, 25 Dec 2022 14:25:59 +0100 Subject: Add `timeout` parameter for SentinelManagedConnection (#2495) --- CHANGES | 1 + redis/asyncio/sentinel.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index b16fbce..72b896b 100644 --- a/CHANGES +++ b/CHANGES @@ -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 -- cgit v1.2.1