summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2022-01-26 16:50:48 +0200
committerGitHub <noreply@github.com>2022-01-26 16:50:48 +0200
commit26491dc25bfc88ea5c9b26d18daf38e3227db751 (patch)
treeda0635d38106dc8f3ccc12ea4bc9cd4e3dda452f
parentfb53a89587d2467cb8253801a9f95c06422e895f (diff)
downloadredis-py-26491dc25bfc88ea5c9b26d18daf38e3227db751.tar.gz
Fixing AttributeError on some connection errors (#1905)
-rwxr-xr-xredis/connection.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 100f902..891695d 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -806,15 +806,18 @@ class Connection:
def read_response(self, disable_decoding=False):
"""Read the response from a previously sent command"""
try:
+ hosterr = f"{self.host}:{self.port}"
+ except AttributeError:
+ hosterr = "connection"
+
+ try:
response = self._parser.read_response(disable_decoding=disable_decoding)
except socket.timeout:
self.disconnect()
- raise TimeoutError(f"Timeout reading from {self.host}:{self.port}")
+ raise TimeoutError(f"Timeout reading from {hosterr}")
except OSError as e:
self.disconnect()
- raise ConnectionError(
- f"Error while reading from {self.host}:{self.port}" f" : {e.args}"
- )
+ raise ConnectionError(f"Error while reading from {hosterr}" f" : {e.args}")
except BaseException:
self.disconnect()
raise