diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index 1f34e03011..5823d2f935 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -2350,10 +2350,11 @@ async def reset(self): # watching something if self._transaction_connection: try: - # call this manually since our unwatch or - # immediate_execute_command methods can call reset() - await self._transaction_connection.send_command("UNWATCH") - await self._transaction_connection.read_response() + if self._watching: + # call this manually since our unwatch or + # immediate_execute_command methods can call reset() + await self._transaction_connection.send_command("UNWATCH") + await self._transaction_connection.read_response() # we can safely return the connection to the pool here since we're # sure we're no longer WATCHing anything self._transaction_node.release(self._transaction_connection) diff --git a/redis/cluster.py b/redis/cluster.py index db9e3e05f7..dbcf5cc2b7 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -3289,10 +3289,11 @@ def reset(self): # watching something if self._transaction_connection: try: - # call this manually since our unwatch or - # immediate_execute_command methods can call reset() - self._transaction_connection.send_command("UNWATCH") - self._transaction_connection.read_response() + if self._watching: + # call this manually since our unwatch or + # immediate_execute_command methods can call reset() + self._transaction_connection.send_command("UNWATCH") + self._transaction_connection.read_response() # we can safely return the connection to the pool here since we're # sure we're no longer WATCHing anything node = self._nodes_manager.find_connection_owner(