In my script, requests.get
never returns:
import requests print ("requesting..") # This call never returns! r = requests.get( "http://www.some-site.com", proxies = {'http': '222.255.169.74:8080'}, ) print(r.ok)
What could be the possible reason(s)? Any remedy? What is the default timeout that get
uses?
The default timeout is None , which means it'll wait (hang) until the connection is closed.
The HyperText Transfer Protocol (HTTP) 408 Request Timeout response status code means that the server would like to shut down this unused connection. It is sent on an idle connection by some servers, even without any previous request by the client.
The get() method sends a GET request to the specified url.
Since Python 3.5, there's a handy and recommended run() API in subprocess module, which has built-in timeout support.
What is the default timeout that get uses?
The default timeout is None
, which means it'll wait (hang) until the connection is closed.
Just specify a timeout value, like this:
r = requests.get( 'http://www.justdial.com', proxies={'http': '222.255.169.74:8080'}, timeout=5 )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With