Skip to content

Commit 35b7e09

Browse files
Kristjan/issue redis#2754: Add missing argument to SentinelManagedConnection.read_response() (redis#2756)
* Increase timeout for a test which would hang completely if failing. Timeouts in virtualized CI backends can occasionally fail if too short. * add "disconnect_on_error" argument to SentinelManagedConnection * update Changes * lint
1 parent f056118 commit 35b7e09

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fix #2754, adding a missing argument to SentinelManagedConnection
12
* Fix `xadd` command to accept non-negative `maxlen` including 0
23
* Revert #2104, #2673, add `disconnect_on_error` option to `read_response()` (issues #2506, #2624)
34
* Add `address_remap` parameter to `RedisCluster`

redis/asyncio/sentinel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ async def read_response(
6767
self,
6868
disable_decoding: bool = False,
6969
timeout: Optional[float] = None,
70+
*,
71+
disconnect_on_error: Optional[float] = True,
7072
):
7173
try:
7274
return await super().read_response(
7375
disable_decoding=disable_decoding,
7476
timeout=timeout,
77+
disconnect_on_error=disconnect_on_error,
7578
)
7679
except ReadOnlyError:
7780
if self.connection_pool.is_master:

redis/sentinel.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import random
22
import weakref
3+
from typing import Optional
34

45
from redis.client import Redis
56
from redis.commands import SentinelCommands
@@ -53,9 +54,14 @@ def _connect_retry(self):
5354
def connect(self):
5455
return self.retry.call_with_retry(self._connect_retry, lambda error: None)
5556

56-
def read_response(self, disable_decoding=False):
57+
def read_response(
58+
self, disable_decoding=False, *, disconnect_on_error: Optional[bool] = False
59+
):
5760
try:
58-
return super().read_response(disable_decoding=disable_decoding)
61+
return super().read_response(
62+
disable_decoding=disable_decoding,
63+
disconnect_on_error=disconnect_on_error,
64+
)
5965
except ReadOnlyError:
6066
if self.connection_pool.is_master:
6167
# When talking to a master, a ReadOnlyError when likely

tests/test_asyncio/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,7 @@ async def helper():
30513051
# the task is now sleeping, lets send it an exception
30523052
task.cancel()
30533053
# If all is well, the task should finish right away, otherwise fail with Timeout
3054-
async with async_timeout(0.1):
3054+
async with async_timeout(1.0):
30553055
await task
30563056

30573057

0 commit comments

Comments
 (0)