Skip to content

Commit c201cf6

Browse files
committed
feat: Add error handling for EXEC command response with retry logic consideration
1 parent 68172e0 commit c201cf6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

redis/connection.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,19 @@ def on_connect(self):
435435
else:
436436
raise AuthenticationError() from e
437437

438+
def _read_exec_responses(self):
439+
# read the response for EXEC which should be a list
440+
response = self.read_response()
441+
if response == b'OK' and not self.retry_on_timeout:
442+
# EXEC did not execute correctly, likely due to previous error
443+
raise ConnectionError("EXEC command did not execute correctly")
444+
while response == b'QUEUED':
445+
response = self.read_response()
446+
if not isinstance(response, list) and not self.retry_on_timeout:
447+
raise ConnectionError(f"EXEC command did not return a list: {response}")
448+
return response
449+
450+
438451
def disconnect(self, *args):
439452
"Disconnects from the Redis server"
440453
self._parser.on_disconnect()

0 commit comments

Comments
 (0)