Skip to content

Commit da27f4b

Browse files
pall-jdvora-h
andauthored
Fix timeout retrying on Redis pipeline execution (#2812)
Achieved by modifying Pipeline._disconnect_raise_reset Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
1 parent 66bad8e commit da27f4b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

redis/client.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ def load_scripts(self):
13791379
def _disconnect_raise_reset(self, conn, error):
13801380
"""
13811381
Close the connection, raise an exception if we were watching,
1382-
and raise an exception if retry_on_timeout is not set,
1382+
and raise an exception if TimeoutError is not part of retry_on_error,
13831383
or the error is not a TimeoutError
13841384
"""
13851385
conn.disconnect()
@@ -1390,11 +1390,13 @@ def _disconnect_raise_reset(self, conn, error):
13901390
raise WatchError(
13911391
"A ConnectionError occurred on while watching one or more keys"
13921392
)
1393-
# if retry_on_timeout is not set, or the error is not
1394-
# a TimeoutError, raise it
1395-
if not (conn.retry_on_timeout and isinstance(error, TimeoutError)):
1393+
# if TimeoutError is not part of retry_on_error, or the error
1394+
# is not a TimeoutError, raise it
1395+
if not (
1396+
TimeoutError in conn.retry_on_error and isinstance(error, TimeoutError)
1397+
):
13961398
self.reset()
1397-
raise
1399+
raise error
13981400

13991401
def execute(self, raise_on_error=True):
14001402
"""Execute all the commands in the current pipeline"""

0 commit comments

Comments
 (0)