Skip to content

Commit 136879e

Browse files
committed
unassign n.connection at every loop
1 parent 3341082 commit 136879e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

redis/cluster.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ def _send_cluster_commands(
20062006
except (ConnectionError, TimeoutError) as e:
20072007
for n in nodes.values():
20082008
n.connection_pool.release(n.connection)
2009+
n.connection = None
20092010
nodes = {}
20102011
if self.retry and isinstance(
20112012
e, self.retry._supported_errors
@@ -2060,6 +2061,7 @@ def _send_cluster_commands(
20602061
# a mismatched result.
20612062
for n in nodes.values():
20622063
n.connection_pool.release(n.connection)
2064+
n.connection = None
20632065
nodes = {}
20642066

20652067
# if the response isn't an exception it is a
@@ -2127,8 +2129,9 @@ def _send_cluster_commands(
21272129
# since we cant guarantee the state of the connections,
21282130
# disconnect before returning it to the connection pool
21292131
for n in nodes.values():
2130-
n.connection.disconnect()
2131-
n.connection_pool.release(n.connection)
2132+
if n.connection:
2133+
n.connection.disconnect()
2134+
n.connection_pool.release(n.connection)
21322135
raise
21332136

21342137
def _fail_on_redirect(self, allow_redirections):

0 commit comments

Comments
 (0)