Skip to content

Commit

Permalink
unassign n.connection at every loop
Browse files Browse the repository at this point in the history
  • Loading branch information
zach-iee committed Jul 19, 2023
1 parent 3341082 commit 136879e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,7 @@ def _send_cluster_commands(
except (ConnectionError, TimeoutError) as e:
for n in nodes.values():
n.connection_pool.release(n.connection)
n.connection = None
nodes = {}
if self.retry and isinstance(
e, self.retry._supported_errors
Expand Down Expand Up @@ -2060,6 +2061,7 @@ def _send_cluster_commands(
# a mismatched result.
for n in nodes.values():
n.connection_pool.release(n.connection)
n.connection = None
nodes = {}

# if the response isn't an exception it is a
Expand Down Expand Up @@ -2127,8 +2129,9 @@ def _send_cluster_commands(
# since we cant guarantee the state of the connections,
# disconnect before returning it to the connection pool
for n in nodes.values():
n.connection.disconnect()
n.connection_pool.release(n.connection)
if n.connection:
n.connection.disconnect()
n.connection_pool.release(n.connection)
raise

def _fail_on_redirect(self, allow_redirections):
Expand Down

0 comments on commit 136879e

Please sign in to comment.