From b46e67163692cd0796763e5c9e17394821d9280c Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 19 Oct 2020 06:27:38 +0100 Subject: [PATCH] Disconnect when execution is cancelled (#172) --- aredis/pipeline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aredis/pipeline.py b/aredis/pipeline.py index c643f75b..90368d5a 100644 --- a/aredis/pipeline.py +++ b/aredis/pipeline.py @@ -2,6 +2,7 @@ import sys from itertools import chain +import aredis from aredis.client import (StrictRedis, StrictRedisCluster) from aredis.exceptions import (AskError, ClusterTransactionError, ConnectionError, ExecAbortError, MovedError, RedisClusterException, RedisError, ResponseError, TimeoutError, TryAgainError, @@ -283,7 +284,7 @@ async def execute(self, raise_on_error=True): try: return await exec(conn, stack, raise_on_error) - except (ConnectionError, TimeoutError) as e: + except (ConnectionError, TimeoutError, aredis.compat.CancelledError) as e: conn.disconnect() if not conn.retry_on_timeout and isinstance(e, TimeoutError): raise