-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
-
Minor Change
Before Python 3.2, the ssl module did not distinguish between timeouts and other ssl exceptions. See https://bugs.python.org/issue10272.
In CPython 2.6 and 2.7 the ssl module raises a generic ssl.SSLError on socket timeouts. The error has a single attribute, message, set to 'The read operation timed out'.
One improvement would be:
def _raise_connection_failure(address, error): """Convert a socket.error to ConnectionFailure and raise it.""" host, port = address # If connecting to a Unix socket, port will be None. if port is not None: msg = '%s:%d: %s' % (host, port, error) else: msg = '%s: %s' % (host, error) if isinstance(error, socket.timeout): raise NetworkTimeout(msg) elif isinstance(error, SSLError) and 'timed out' in error.message: raise NetworkTimeout(msg) else: raise AutoReconnect(msg)
Research needs to be done to make sure this is portable on supported versions of CPython, PyPy, and PyPy3.
- is related to
-
PYTHON-2596 Connection errors should always include the host in the error message
- Closed