Chromium Code Reviews| Index: rietveld.py |
| diff --git a/rietveld.py b/rietveld.py |
| index f6ccaf928f1041dca6c00100f477a4e141ed796a..be6386473aa146db6e2ff2f2c9df37af13f971a4 100644 |
| --- a/rietveld.py |
| +++ b/rietveld.py |
| @@ -97,7 +97,20 @@ class Rietveld(object): |
| url = '/api/%d' % issue |
| if messages: |
| url += '?messages=true' |
| - data = json.loads(self.get(url)) |
| + NUM_RETRIES = 5 |
| + for tries in xrange(NUM_RETRIES): |
| + try: |
| + data = json.loads(self.get(url)) |
|
M-A Ruel
2014/07/28 21:11:38
It'd be more sane to add a retry_404=True flag to
hinoka
2014/08/27 13:42:47
Done.
|
| + except urllib2.HTTPError as e: |
| + if e.code == 404: |
| + # 404 might indicate datastore lag. Wait and try again. |
| + if tries < NUM_RETRIES - 1: |
| + time.sleep(2 ** tries) |
| + continue |
| + raise |
| + else: |
| + break |
| + |
| data['description'] = '\n'.join(data['description'].strip().splitlines()) |
| return data |