From 0e30d8da4d1e7cba14bce4ab0e247a97d492d142 Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Mon, 17 Jan 2022 10:17:39 +0000 Subject: Add retries to connections in Sentinel Pools (#1879) --- redis/sentinel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1