diff options
author | Kristján Valur Jónsson <sweskman@gmail.com> | 2022-05-08 12:03:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 15:03:52 +0300 |
commit | c25be04d6468163d31908774ed358d3fd6bc0a39 (patch) | |
tree | 582966d5da7080849c5fe4fecae764e3b4c0fcb3 /redis/asyncio/connection.py | |
parent | 963843b4379eced5ab20d0682f24438962e9eb0f (diff) | |
download | redis-py-c25be04d6468163d31908774ed358d3fd6bc0a39.tar.gz |
Replace OSError exceptions from `can_read` with `redis.ConnectionError` (#2140)
* Replace OSError exceptions from `can_read` with `redis.ConnectionError`
* Fix formatting
* Revert unintended formatting change
Diffstat (limited to 'redis/asyncio/connection.py')
-rw-r--r-- | redis/asyncio/connection.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index f0e6d3d..91961ba 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -911,7 +911,13 @@ class Connection: """Poll the socket to see if there's data that can be read.""" if not self.is_connected: await self.connect() - return await self._parser.can_read(timeout) + try: + return await self._parser.can_read(timeout) + except OSError as e: + await self.disconnect() + raise ConnectionError( + f"Error while reading from {self.host}:{self.port}: {e.args}" + ) async def read_response(self, disable_decoding: bool = False): """Read the response from a previously sent command""" |