data None for in xrange try data urllib urlopen uri read except IOErro

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data = None
for x in xrange(5):
try:
data = urllib.urlopen(uri).read()
except IOError, ex:
logging.debug('try #%d: %s' % (x, ex))
else:
break
return data