Skip to content

Commit 438a54e

Browse files
tzongwManelCoutinhoSensei
authored andcommitted
TransactionStrategy reset: UNWATCH only when status is watching (#3671)
1 parent bbd63ec commit 438a54e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

redis/asyncio/cluster.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,10 +2352,11 @@ async def reset(self):
23522352
# watching something
23532353
if self._transaction_connection:
23542354
try:
2355-
# call this manually since our unwatch or
2356-
# immediate_execute_command methods can call reset()
2357-
await self._transaction_connection.send_command("UNWATCH")
2358-
await self._transaction_connection.read_response()
2355+
if self._watching:
2356+
# call this manually since our unwatch or
2357+
# immediate_execute_command methods can call reset()
2358+
await self._transaction_connection.send_command("UNWATCH")
2359+
await self._transaction_connection.read_response()
23592360
# we can safely return the connection to the pool here since we're
23602361
# sure we're no longer WATCHing anything
23612362
self._transaction_node.release(self._transaction_connection)

redis/cluster.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,10 +3289,11 @@ def reset(self):
32893289
# watching something
32903290
if self._transaction_connection:
32913291
try:
3292-
# call this manually since our unwatch or
3293-
# immediate_execute_command methods can call reset()
3294-
self._transaction_connection.send_command("UNWATCH")
3295-
self._transaction_connection.read_response()
3292+
if self._watching:
3293+
# call this manually since our unwatch or
3294+
# immediate_execute_command methods can call reset()
3295+
self._transaction_connection.send_command("UNWATCH")
3296+
self._transaction_connection.read_response()
32963297
# we can safely return the connection to the pool here since we're
32973298
# sure we're no longer WATCHing anything
32983299
node = self._nodes_manager.find_connection_owner(

0 commit comments

Comments
 (0)