Very occasionally when making a http request, I am waiting for an age for a response that never comes. What is the recommended way to cancel this request after a reasonable period of time?
I must be pretty tired, not to think to look there first, Thanks!
wodemoneke
2009-03-25 21:35:24
+1
A:
The timeout parameter to urllib2.urlopen, or httplib. The original urllib has no such convenient feature. You can also use an asynchronous HTTP client such as twisted.web.client, but that's probably not necessary.
Devin Jeanpierre
2009-03-25 21:28:29
+1
A:
If you are making a lot of HTTP requests, you can change this globally by calling socket.setdefaulttimeout
Sebastian Celis
2009-03-25 21:35:52
Thanks, I'm doing this because it seems that the timeout parameter was only added in python 2.6 and I need to support 2.5 as. well
wodemoneke
2009-03-26 07:28:27