From 75fc8f6daf6f5666eff088ccd68c73ea6396a706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 23 Jun 2022 18:03:11 +0000 Subject: [PATCH] Remove redundant checks for asyncio.CancelledError --- redis/asyncio/connection.py | 4 +--- tests/test_asyncio/test_pubsub.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 60e974cf5f..e8f0af02b4 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -502,8 +502,6 @@ async def read_from_socket( # data was read from the socket and added to the buffer. # return True to indicate that data was read. return True - except asyncio.CancelledError: - raise except (socket.timeout, asyncio.TimeoutError): if raise_on_timeout: raise TimeoutError("Timeout reading from socket") from None @@ -722,7 +720,7 @@ async def connect(self): lambda: self._connect(), lambda error: self.disconnect() ) except asyncio.CancelledError: - raise + raise # in 3.7 and earlier, this is an Exception, not BaseException except (socket.timeout, asyncio.TimeoutError): raise TimeoutError("Timeout connecting to server") except OSError as e: diff --git a/tests/test_asyncio/test_pubsub.py b/tests/test_asyncio/test_pubsub.py index 7f7d19010e..555cfdbc77 100644 --- a/tests/test_asyncio/test_pubsub.py +++ b/tests/test_asyncio/test_pubsub.py @@ -917,7 +917,7 @@ async def loop_step_listen(self): except asyncio.TimeoutError: return False - + @pytest.mark.onlynoncluster class TestBaseException: @pytest.mark.skipif(