-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
requests.get() timeout times out after twice the given value #5760
Comments
In the future, please search closed and open issues before creating new ones that are duplicates. |
Hello @sigmavirus24 thank you for your response. I did do that but could not find one. I can of course only judge by the issue's title and what github search can afford to show me. Can you please at least link the issue for which you are closing this one as a duplicate? Thanks in advance. |
One such issue I could find is #5450, the issue was closed but not solved. I'm also experiencing this problem, and requests is consistently timing out after approximately twice the specified timeout. This is not a precision problem, this is an actual bug! Please reopen either this or the other issue! Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time, requests
>>> requests.__version__
'2.25.1'
>>> requests.urllib3.__version__
'1.26.3'
>>> def test_timeout(timeout=1, url='http://google.com:81'):
... start = time.time()
... try:
... requests.get(url, timeout=timeout)
... except requests.ConnectTimeout:
... print(time.time()-start)
...
>>> for i in range(1, 11):
... test_timeout(i)
...
2.0313971042633057
4.0080249309539795
6.010318040847778
8.012223482131958
10.014029264450073
12.012367725372314
14.017669200897217
16.01678204536438
18.01997184753418
20.043574571609497
>>> This is a |
I made a simple example script to showcase what I experienced
Expected Result
I expected this to timeout after 4 seconds and per the given timeout.
Actual Result
What happens instead is that the timeout exception is raised after 2x the given timeout argument.
System Information
The text was updated successfully, but these errors were encountered: