Skip to content

Commit

Permalink
fix:Remove the condition that checks for connection retries
Browse files Browse the repository at this point in the history
This update eliminates the condition checking for connection retries because the logic was refactored to execute MULTI and EXEC commands within the same try block. This adjustment resolves the issue with unintended reconnection attempts, ensuring proper handling of transactional commands
  • Loading branch information
zeze1004 committed Jun 13, 2024
1 parent eae6d46 commit c4c21d0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,21 @@ def on_connect(self):
self.send_command('EXEC')
responses = self._read_exec_responses()
self._handle_responses(responses, auth_args)
except (TimeoutError, AuthenticationError, ConnectionError) as e:
if not self.retry_on_timeout:
raise e
except Exception as e:
except AuthenticationError as e:
if str(e) == "Invalid Username or Password":
raise AuthenticationError("Invalid Username or Password") from e
else:
raise AuthenticationError() from e
except Exception:
raise ConnectionError("Error during EXEC handling")

def _read_exec_responses(self):
# read the response for EXEC which should be a list
response = self.read_response()
if response == b'OK' and not self.retry_on_timeout:
if response == b'OK':
# EXEC did not execute correctly, likely due to previous error
raise ConnectionError("EXEC command did not execute correctly")
while response == b'QUEUED':
response = self.read_response()
if not isinstance(response, list) and not self.retry_on_timeout:
if not isinstance(response, list):
raise ConnectionError(f"EXEC command did not return a list: {response}")
return response

Expand Down

0 comments on commit c4c21d0

Please sign in to comment.