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