From 04ce530c9416cac5d8662d73ab231f6dee355601 Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Fri, 13 May 2011 21:18:42 +0200 Subject: handle HTTP Error 500: Internal Server Error. just retry 5 times. then fail --- issues.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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): -- cgit v1.2.3