requests: timeout causes exception unrelated to timeout
When I submit a request without specifying a timeout, I get a 404 response (appropriately). For the same URL, requested with a timeout, I immediately get an exception claiming that the remote host has forcibly closed the connection. I can’t imagine how the timeout mechanism could result in this behavior.
H:\tests>python
ActivePython 2.7.10.12 (ActiveState Software Inc.) based on
Python 2.7.10 (default, Aug 21 2015, 12:07:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__version__
'2.13.0'
>>> requests.get("http://www.cancer.gov/cam")
<Response [404]>
>>> requests.get("http://www.cancer.gov/cam", timeout=5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "D:\Python\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "D:\Python\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "D:\Python\lib\site-packages\requests\adapters.py", line 473, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (9 by maintainers)
Thanks for following up here @bkline! Good luck with the bug report: I hope your problem gets resolved soon! ✨