- 论坛徽章:
- 0
|
使用urllib库下载东西,可是经常出现下面的错误。查了一下,别人建议设置超时时间长一些,socket.setsockettimeout(10),我已经把延时设为10妙了,可还经常出现这种情况,我想问问,能不能让程序一直卡在那了,直到可以访问为止??不考虑将超时设为无穷大....
File "601-poco-restaurant.py", line 207, in sendContent
returnValues = urllib.urlopen("http://192.168.2.200/spider/save",params) # 发送
File "/usr/local/lib/python2.5/urllib.py", line 84, in urlopen
return opener.open(url, data)
File "/usr/local/lib/python2.5/urllib.py", line 192, in open
return getattr(self, name)(url, data)
File "/usr/local/lib/python2.5/urllib.py", line 328, in open_http
errcode, errmsg, headers = h.getreply()
File "/usr/local/lib/python2.5/httplib.py", line 1199, in getreply
response = self._conn.getresponse()
File "/usr/local/lib/python2.5/httplib.py", line 928, in getresponse
response.begin()
File "/usr/local/lib/python2.5/httplib.py", line 385, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python2.5/httplib.py", line 343, in _read_status
line = self.fp.readline()
File "/usr/local/lib/python2.5/socket.py", line 331, in readline
data = recv(1)
IOError: [Errno socket error] timed out |
|