Python - Urllib2 Timeout
I got something below is snippet of my code opener = urllib2.build_opener(redirect_handler.MyHTTPRedirectHandler()) opener.addheaders = [('Accept-encoding', 'gzip')] fetch_timeout
Solution 1:
At a guess you probably need to set the socket timeout
importsocketdefault_timeout=12
socket.setdefaulttimeout(default_timeout)
Solution 2:
Which version are you using. It was added in 2.6
Also the method is
urllib2.urlopen(url[, data][, timeout])
Can you try providing
self.response = opener.open(url, None, fetch_timeout)
Yeah for all others, you could still use socket module to set socket time out.
Solution 3:
Look at the OpenerDirector class and the urllib2.install_opener() method.
Post a Comment for "Python - Urllib2 Timeout"