Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3090] Reduce Command Responses in Redis Connection Process (on_connect) #3268

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix:Remove the condition that checks for connection retries
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
zeze1004 committed Jun 13, 2024

Verified

This commit was signed with the committer’s verified signature.
varun7654 Adalie Ahuja
commit c4c21d06f7930e0110e617c8be5fcbdf8d776c47
13 changes: 5 additions & 8 deletions redis/connection.py
Original file line number Diff line number Diff line change
@@ -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