Here is my ugly little code snippet now:
for i in range(5):
try:
self.startTime=time.time()
self.rawfeed=requests.get(self.feedurl)
continue
except ConnectionError:
print "Got a connection error. Retrying", i
time.sleep(i*i) # giving a bit longer wait each time
pass
if i == 5: raise
self.ResponseTime=time.time()-self.startTime
Two problems here. First my except statement does not seem to recognize "ConnectionError" as an exception (SOLVED, thanks, stackers), but rather complains that it isn't a global variable. And second, and more important, I would really like to know if the error is MY side, or the SERVER's side.
Typically I want to retry on MY errors, but give up and report on a SERVER error. (By "MY" error, I mean anything other than a server error.)
elseclause on for loops: docs.python.org/release/1.5/tut/node23.html