Skip to content

Commit

Permalink
Change ssl to return a socket.timeout exception on timeout instead of…
Browse files Browse the repository at this point in the history
… an SSLError

Back in Python 3.2, ssl.SSLError used to be a subclass of socket.error (see
https://docs.python.org/3/library/ssl.html#exceptions), so timeouts on
monkeypatched ssl sockets would be properly caught by socket.timeout
excpetion handlers in applications.  However, since Python 3.3 ssl.SSLerror
is a subclass of OSError, which signifies a different (typically fatal)
type of error that is usually not handled gracefully by applications.

By changing the timeout excpetion back to socket.timeout, libraries such
as pymysql and redis will again properly support TLS-connections in
monkeypatched apoplications.
  • Loading branch information
baszoetekouw authored and temoto committed Jan 18, 2023
1 parent b034167 commit caf9f99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion eventlet/green/ssl.py
Expand Up @@ -15,7 +15,7 @@

orig_socket = __import__('socket')
socket = orig_socket.socket
timeout_exc = SSLError
timeout_exc = orig_socket.timeout

__patched__ = [
'SSLSocket', 'SSLContext', 'wrap_socket', 'sslwrap_simple',
Expand Down

0 comments on commit caf9f99

Please sign in to comment.