You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect this should always raise a timeout error.
Instead, if you put Windows into "sleep" mode during an openssl handshake, then wake it up a few minute later, socket events are silently dropped and the socket hangs forever.
Then close the laptop lid, and lift it up 5 minutes later (or whatever the tcp discard window is). The get request never times out, and never returns. If someone knows a better way of making a socket "disappear" and not time out, let me know.
It's possible to get a call stack by turning on python's tracing system and killing the process:
Call stack of hung thread:
Thread 0x000070000823a000 (most recent call first):
File "site-packages/OpenSSL/SSL.py", line 1813 in recv_into
File "site-packages/urllib3/contrib/pyopenssl.py", line 313 in recv_into
File "socket.py", line 586 in readinto
File "http/client.py", line 258 in _read_status
File "http/client.py", line 297 in begin
File "http/client.py", line 1331 in getresponse
File "site-packages/urllib3/connectionpool.py", line 421 in _make_request
File "site-packages/urllib3/connectionpool.py", line 677 in urlopen
File "site-packages/requests/adapters.py", line 449 in send
File "site-packages/requests/sessions.py", line 643 in send
Related Issue with pyopenssl:
pyopnessl, by not doing it themselves, has essentially decided that the caller must handle this by putting the socket into non-blocking mode, and calling select in a loop:
@earonesty I belive you're confused about what functionality timeout provides in requests. Please search open and closed issues and read those, or read the docs
Summary.
Assume you have a website that listens for and accepts connections, but never responds.
requests.get('https://sitethatneverresponds.com', timeout=1)
I expect this should always raise a timeout error.
Instead, if you put Windows into "sleep" mode during an openssl handshake, then wake it up a few minute later, socket events are silently dropped and the socket hangs forever.
Reproduction Steps
On a laptop run do this a bunch of times:
requests.get('https://sitethatneverresponds.com', timeout=1)
Then close the laptop lid, and lift it up 5 minutes later (or whatever the tcp discard window is). The get request never times out, and never returns. If someone knows a better way of making a socket "disappear" and not time out, let me know.
It's possible to get a call stack by turning on python's tracing system and killing the process:
Call stack of hung thread:
Related Issue with pyopenssl:
pyopnessl, by not doing it themselves, has essentially decided that the caller must handle this by putting the socket into non-blocking mode, and calling select in a loop:
See: pyca/pyopenssl#168 for potential solutions.
System Information
The text was updated successfully, but these errors were encountered: