summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Zeyer <albert.zeyer@rwth-aachen.de>2011-05-13 21:18:42 +0200
committerAlbert Zeyer <albert.zeyer@rwth-aachen.de>2011-05-13 21:18:42 +0200
commit04ce530c9416cac5d8662d73ab231f6dee355601 (patch)
tree196c73b7cfd7bc5374d9d3ca57b7394d4fa17eee
parente59ac40fb5a862f29caa15ede18a1bcdaa24d8d5 (diff)
handle HTTP Error 500: Internal Server Error. just retry 5 times. then fail
-rwxr-xr-xissues.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/issues.py b/issues.py
index 27f65ca..3e56a86 100755
--- a/issues.py
+++ b/issues.py
@@ -48,6 +48,7 @@ def __rest_call_unchecked(before, after, data_dict=None):
return response
def rest_call(before, after, data_dict=None):
+ count500err = 0
while True:
try:
return __rest_call_unchecked(before, after, data_dict)
@@ -60,6 +61,13 @@ def rest_call(before, after, data_dict=None):
l /= 2
data_dict = dict(map(lambda (k,v): (k,v[0:l]), data_dict.iteritems()))
continue
+ elif e.code == 500:
+ N = 5
+ if count500err >= N: raise e
+ print "Waiting 10 seconds, will try", (N - count500err), "more times"
+ sleep(10)
+ count500err += 1
+ continue
raise e # reraise, we cannot handle it
def labelify(string):