From d4e11c3c24a230ebc073127375d2c454c88bfc61 Mon Sep 17 00:00:00 2001 From: Jessie Chen Date: Tue, 1 Aug 2023 13:23:05 -0700 Subject: [PATCH] Raise OperationalError for socket timeouts --- redshift_connector/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/redshift_connector/core.py b/redshift_connector/core.py index ba1a4c5..36d15b8 100644 --- a/redshift_connector/core.py +++ b/redshift_connector/core.py @@ -658,7 +658,10 @@ def get_calling_module() -> str: self._usock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) except socket.error as e: self._usock.close() - raise InterfaceError("communication error", e) + if socket.timeout: + raise OperationalError("connection time out", e) + else: + raise InterfaceError("communication error", e) self._flush: typing.Callable = self._sock.flush self._read: typing.Callable = self._sock.read self._write: typing.Callable = self._sock.write