Skip to content

Commit

Permalink
Fix timeout retrying on Redis pipeline execution (#2812)
Browse files Browse the repository at this point in the history
Achieved by modifying Pipeline._disconnect_raise_reset

Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
  • Loading branch information
pall-j and dvora-h committed Aug 3, 2023
1 parent 66bad8e commit da27f4b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions redis/client.py
Expand Up @@ -1379,7 +1379,7 @@ def load_scripts(self):
def _disconnect_raise_reset(self, conn, error):
"""
Close the connection, raise an exception if we were watching,
and raise an exception if retry_on_timeout is not set,
and raise an exception if TimeoutError is not part of retry_on_error,
or the error is not a TimeoutError
"""
conn.disconnect()
Expand All @@ -1390,11 +1390,13 @@ def _disconnect_raise_reset(self, conn, error):
raise WatchError(
"A ConnectionError occurred on while watching one or more keys"
)
# if retry_on_timeout is not set, or the error is not
# a TimeoutError, raise it
if not (conn.retry_on_timeout and isinstance(error, TimeoutError)):
# if TimeoutError is not part of retry_on_error, or the error
# is not a TimeoutError, raise it
if not (
TimeoutError in conn.retry_on_error and isinstance(error, TimeoutError)
):
self.reset()
raise
raise error

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

0 comments on commit da27f4b

Please sign in to comment.