Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: rietveld.py

Issue 350433003: Retry fetching patch from rietveld on a 404 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Move to rietveld.py Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698