summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authornbraun-amazon <85549956+nbraun-amazon@users.noreply.github.com>2021-10-14 16:41:15 +0300
committerGitHub <noreply@github.com>2021-10-14 16:41:15 +0300
commit9e8cfaac8bbab84c2340b55e5ac55289834b558b (patch)
treedcf3948d323b348f17b602945d0cde8af0d86d7f /redis/connection.py
parent358c293e7772a44f114c78b5c5129ba1e972240f (diff)
downloadredis-py-9e8cfaac8bbab84c2340b55e5ac55289834b558b.tar.gz
Fix `retry` attribute in UnixDomainSocketConnection (#1604)
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-xredis/connection.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/redis/connection.py b/redis/connection.py
index de30f0c..5528589 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -880,7 +880,13 @@ class UnixDomainSocketConnection(Connection):
encoding_errors='strict', decode_responses=False,
retry_on_timeout=False,
parser_class=DefaultParser, socket_read_size=65536,
- health_check_interval=0, client_name=None):
+ health_check_interval=0, client_name=None,
+ retry=None):
+ """
+ Initialize a new UnixDomainSocketConnection.
+ To specify a retry policy, first set `retry_on_timeout` to `True`
+ then set `retry` to a valid `Retry` object
+ """
self.pid = os.getpid()
self.path = path
self.db = db
@@ -889,6 +895,14 @@ class UnixDomainSocketConnection(Connection):
self.password = password
self.socket_timeout = socket_timeout
self.retry_on_timeout = retry_on_timeout
+ if retry_on_timeout:
+ if retry is None:
+ self.retry = Retry(NoBackoff(), 1)
+ else:
+ # deep-copy the Retry object as it is mutable
+ self.retry = copy.deepcopy(retry)
+ else:
+ self.retry = Retry(NoBackoff(), 0)
self.health_check_interval = health_check_interval
self.next_health_check = 0
self.encoder = Encoder(encoding, encoding_errors, decode_responses)