diff --git a/CHANGES/1129.bugfix b/CHANGES/1129.bugfix new file mode 100644 index 000000000..624d43583 --- /dev/null +++ b/CHANGES/1129.bugfix @@ -0,0 +1 @@ +fixed raw socket.error (or one of its subclasses) raises instead of a redis.exceptions.ConnectionError diff --git a/aioredis/connection.py b/aioredis/connection.py index a368d2d8c..a638f14a5 100644 --- a/aioredis/connection.py +++ b/aioredis/connection.py @@ -901,6 +901,11 @@ async def read_response(self): except asyncio.TimeoutError: await self.disconnect() raise TimeoutError(f"Timeout reading from {self.host}:{self.port}") + except OSError as e: + await self.disconnect() + raise ConnectionError( + f"Error while reading from {self.host}:{self.port} : {e.args}" + ) except BaseException: await self.disconnect() raise diff --git a/aioredis/exceptions.py b/aioredis/exceptions.py index 4aeba5e68..e4c2ed1e4 100644 --- a/aioredis/exceptions.py +++ b/aioredis/exceptions.py @@ -7,7 +7,7 @@ class RedisError(Exception): pass -class ConnectionError(builtins.ConnectionError, RedisError): +class ConnectionError(RedisError): pass