diff options
author | Jonathan Dieter <jdieter@gmail.com> | 2022-01-17 10:17:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-17 12:17:39 +0200 |
commit | 0e30d8da4d1e7cba14bce4ab0e247a97d492d142 (patch) | |
tree | dcc047100c18c529ae13d33f6f6ab218fb19fd4b | |
parent | f0c0ab24e8b1a98fcc1e6bc7cc5c6ecfcd75da85 (diff) | |
download | redis-py-0e30d8da4d1e7cba14bce4ab0e247a97d492d142.tar.gz |
Add retries to connections in Sentinel Pools (#1879)
-rw-r--r-- | redis/sentinel.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/sentinel.py b/redis/sentinel.py index 025ab39..b3f1490 100644 --- a/redis/sentinel.py +++ b/redis/sentinel.py @@ -37,7 +37,7 @@ class SentinelManagedConnection(Connection): if str_if_bytes(self.read_response()) != "PONG": raise ConnectionError("PING failed") - def connect(self): + def _connect_retry(self): if self._sock: return # already connected if self.connection_pool.is_master: @@ -50,6 +50,12 @@ class SentinelManagedConnection(Connection): continue raise SlaveNotFoundError # Never be here + def connect(self): + return self.retry.call_with_retry( + self._connect_retry, + lambda error: None, + ) + def read_response(self, disable_decoding=False): try: return super().read_response(disable_decoding=disable_decoding) |