Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 4b55305

Browse files
FranGMGrokzen
authored andcommitted
Do not attempt to disconnect if connection is none
When handling a ConnectionError we could be faced with the situation that we still don't have a connection, so attempting to disconnect would result in an error. To prevent this, we first check if the connection is None before attempting to disconnect.
1 parent 58bafe4 commit 4b55305

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rediscluster/client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,11 @@ def _execute_command(self, *args, **kwargs):
647647
except ConnectionError:
648648
log.exception("ConnectionError")
649649

650-
connection.disconnect()
650+
# ConnectionError can also be raised if we couldn't get a connection
651+
# from the pool before timing out, so check that this is an actual
652+
# connection before attempting to disconnect.
653+
if connection is not None:
654+
connection.disconnect()
651655
connection_error_retry_counter += 1
652656

653657
# Give the node 0.1 seconds to get back up and retry again with same

0 commit comments

Comments
 (0)