Skip to content

Commit d7eb12f

Browse files
committed
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
1 parent ef18e16 commit d7eb12f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

redis/connection.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -415,24 +415,21 @@ def on_connect(self):
415415
self.send_command('EXEC')
416416
responses = self._read_exec_responses()
417417
self._handle_responses(responses, auth_args)
418-
except (TimeoutError, AuthenticationError, ConnectionError) as e:
419-
if not self.retry_on_timeout:
420-
raise e
421-
except Exception as e:
418+
except AuthenticationError as e:
422419
if str(e) == "Invalid Username or Password":
423420
raise AuthenticationError("Invalid Username or Password") from e
424-
else:
425-
raise AuthenticationError() from e
421+
except Exception:
422+
raise ConnectionError("Error during EXEC handling")
426423

427424
def _read_exec_responses(self):
428425
# read the response for EXEC which should be a list
429426
response = self.read_response()
430-
if response == b'OK' and not self.retry_on_timeout:
427+
if response == b'OK':
431428
# EXEC did not execute correctly, likely due to previous error
432429
raise ConnectionError("EXEC command did not execute correctly")
433430
while response == b'QUEUED':
434431
response = self.read_response()
435-
if not isinstance(response, list) and not self.retry_on_timeout:
432+
if not isinstance(response, list):
436433
raise ConnectionError(f"EXEC command did not return a list: {response}")
437434
return response
438435

0 commit comments

Comments
 (0)