def sub_app_get(self, offset):
count = 0
while True:
try:
f = urllib2.urlopen('http://localhost:5050%s' % offset)
except urllib2.URLError, e:
if hasattr(e, 'reason') and type(e.reason) == urllib2.socket.error:
# i.e. process not started up yet
count += 1
time.sleep(1)
assert count < 5, '%s: %r; %r' % (offset, e, e.args)
else:
print 'Error opening url: %s' % offset
assert 0, e # Print exception
else:
break
return f.read()
评论列表
文章目录