summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2022-05-08 12:03:52 +0000
committerGitHub <noreply@github.com>2022-05-08 15:03:52 +0300
commitc25be04d6468163d31908774ed358d3fd6bc0a39 (patch)
tree582966d5da7080849c5fe4fecae764e3b4c0fcb3 /redis/connection.py
parent963843b4379eced5ab20d0682f24438962e9eb0f (diff)
downloadredis-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/connection.py')
-rwxr-xr-xredis/connection.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/connection.py b/redis/connection.py
index ecbd32f..e0dcfc6 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -808,7 +808,13 @@ class Connection:
sock = self._sock
if not sock:
self.connect()
- return self._parser.can_read(timeout)
+ try:
+ return self._parser.can_read(timeout)
+ except OSError as e:
+ self.disconnect()
+ raise ConnectionError(
+ f"Error while reading from {self.host}:{self.port}: {e.args}"
+ )
def read_response(self, disable_decoding=False):
"""Read the response from a previously sent command"""