diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2023-03-29 16:50:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-29 16:50:37 +0300 |
commit | 49d9cb751c7c30546fc86d11f8168d7aa007edae (patch) | |
tree | b940ea97748b242c40a6b7c2d2e87cabf4d002d8 /redis/asyncio/cluster.py | |
parent | b3c89acd0ffe8303649ad8207bc911b1d6a033eb (diff) | |
download | redis-py-4.4.tar.gz |
* Fixing cancelled async futures (#2666)
Co-authored-by: James R T <jamestiotio@gmail.com>
Co-authored-by: dvora-h <dvora.heller@redis.com>
* Version 4.4.4
* fix tests
* linters
* fixing the test for the 4.4 state
* remove superfluous try-except
---------
Co-authored-by: Chayim <chayim@users.noreply.github.com>
Co-authored-by: James R T <jamestiotio@gmail.com>
Co-authored-by: Chayim I. Kirshen <c@kirshen.com>
Diffstat (limited to 'redis/asyncio/cluster.py')
-rw-r--r-- | redis/asyncio/cluster.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index 569a076..a4a9561 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -1016,6 +1016,19 @@ class ClusterNode: finally: self._free.append(connection) + async def _try_parse_response(self, cmd, connection, ret): + try: + cmd.result = await asyncio.shield( + self.parse_response(connection, cmd.args[0], **cmd.kwargs) + ) + except asyncio.CancelledError: + await connection.disconnect(nowait=True) + raise + except Exception as e: + cmd.result = e + ret = True + return ret + async def execute_pipeline(self, commands: List["PipelineCommand"]) -> bool: # Acquire connection connection = self.acquire_connection() @@ -1028,13 +1041,7 @@ class ClusterNode: # Read responses ret = False for cmd in commands: - try: - cmd.result = await self.parse_response( - connection, cmd.args[0], **cmd.kwargs - ) - except Exception as e: - cmd.result = e - ret = True + ret = await asyncio.shield(self._try_parse_response(cmd, connection, ret)) # Release connection self._free.append(connection) |