Skip to content

Commit dcebbf5

Browse files
committed
TransactionStrategy reset: UNWATCH only when status is watching
1 parent 06fac1d commit dcebbf5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

redis/asyncio/cluster.py

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

redis/cluster.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,8 +3292,9 @@ def reset(self):
32923292
try:
32933293
# call this manually since our unwatch or
32943294
# immediate_execute_command methods can call reset()
3295-
self._transaction_connection.send_command("UNWATCH")
3296-
self._transaction_connection.read_response()
3295+
if self._watching:
3296+
self._transaction_connection.send_command("UNWATCH")
3297+
self._transaction_connection.read_response()
32973298
# we can safely return the connection to the pool here since we're
32983299
# sure we're no longer WATCHing anything
32993300
node = self._nodes_manager.find_connection_owner(

0 commit comments

Comments
 (0)