1
KhadainJHIN OP try except 没有起作用...程序没有中断..
|
2
KhadainJHIN OP 查询到结果原因为连接被远端重置...设置 urlopen(timeout)是否有用..另外链接被重置 程序为何没有响应...
|
3
bazingaterry 2017-06-28 11:35:54 +08:00 via iPhone
贴代码...
|
4
KhadainJHIN OP @bazingaterry
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib64/python2.6/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib64/python2.6/urllib2.py", line 409, in _open '_open', req) File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open return self.do_open( httplib.HTTPConnection, req) File "/usr/lib64/python2.6/urllib2.py", line 1163, in do_open r = h.getresponse() File "/usr/lib64/python2.6/httplib.py", line 990, in getresponse response.begin() File "/usr/lib64/python2.6/httplib.py", line 391, in begin version, status, reason = self._read_status() File "/usr/lib64/python2.6/httplib.py", line 349, in _read_status line = self.fp.readline() File "/usr/lib64/python2.6/socket.py", line 433, in readline data = recv(1) KeyboardInterrupt 不能发代码... |
5
KhadainJHIN OP @bazingaterry
request = urllib2.Request(url) while condition : time = 重连次数 for t in range(time): try: time.sleep(0.5) res = urllib2.urlopen(request,json) except urllib2.URLError, e: if t < (time-1): record_log() m = res.read() 伪代码.. |
6
douxie 2017-06-28 23:38:23 +08:00
表示没看懂你说的啥意思,代码也不全
|