"Mahesh" advised:
>
> Timing it out will probably solve it.
>
Thanks.
Follow-on question regarding implementing a timeout for use by urllib2. I am
guessing the simplest way to do this is via socket.setdefaulttimeout(), but I
am not sure if this sets a global parameter, and if so, whether it might be
reset via instantiations of urllib, urllib2, httplib, etc. I assume socket and
the timeout parameter is in the global namespace and that I can just reset it
at will for application to all the socket module 'users'. Is that right?
(TIA)
[experimenting]
>>> import urllib2plus
>>> urllib2plus.setSocketTimeOut(1)
>>> urllib2plus.urlopen('http://zomething.com')
Traceback (most recent call last):
File "", line 1, in -toplevel-
urllib2plus.urlopen('http://zomething.com')
File "C:\Python24\lib\urllib2plus.py", line 130, in urlopen
return _opener.open(url, data)
File "C:\Python24\lib\urllib2plus.py", line 361, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2plus.py", line 379, in _open
'_open', req)
File "C:\Python24\lib\urllib2plus.py", line 340, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2plus.py", line 1024, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python24\lib\urllib2plus.py", line 999, in do_open
raise URLError(err)
URLError:
>>> urllib2plus.setSocketTimeOut(10)
>>> urllib2plus.urlopen('http://zomething.com')
>
>>> import socket
>>> socket.setdefaulttimeout(0)
>>> urllib2plus.urlopen('http://zomething.com')
Traceback (most recent call last):
File "", line 1, in -toplevel-
urllib2plus.urlopen('http://zomething.com')
File "C:\Python24\lib\urllib2plus.py", line 130, in urlopen
return _opener.open(url, data)
File "C:\Python24\lib\urllib2plus.py", line 361, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2plus.py", line 379, in _open
'_open', req)
File "C:\Python24\lib\urllib2plus.py", line 340, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2plus.py", line 1024, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python24\lib\urllib2plus.py", line 999, in do_open
raise URLError(err)
URLError:
>>> socket.setdefaulttimeout(1)
>>> urllib2plus.urlopen('http://zomething.com')
>
--
http://mail.python.org/mailman/listinfo/python-list