The program is as follows:
HEADER CODE
urllib2.initialization()
try:
while True:
urllib2.read(somebytes)
urllib2.read(somebytes)
urllib2.read(somebytes)
...
except Exception, e:
print e
FOOTER CODE
My question is when an error occurs (timeout, connection reset by peer, etc.), how to restart from urllib2.initialization () instead of the existing main program and restart from HEADER CODE again?
source
share