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

Unified Diff: rietveld.py

Issue 932333003: Make maxtries for Rietveld configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 10 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 f5832de4e0eb761cbc31e53f274175d9c68c6f5f..c64235bb88fd6b94c32ec23892ccd3ef40de786f 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -37,7 +37,7 @@ upload.LOGGER.setLevel(logging.WARNING) # pylint: disable=E1103
class Rietveld(object):
"""Accesses rietveld."""
- def __init__(self, url, email, password, extra_headers=None):
+ def __init__(self, url, email, password, extra_headers=None, maxtries=None):
self.url = url.rstrip('/')
# Email and password are accessed by commit queue, keep them.
self.email = email
@@ -64,6 +64,8 @@ class Rietveld(object):
self._xsrf_token = None
self._xsrf_token_time = None
+ self._maxtries = maxtries or 40
+
def xsrf_token(self):
if (not self._xsrf_token_time or
(time.time() - self._xsrf_token_time) > 30*60):
@@ -413,8 +415,7 @@ class Rietveld(object):
old_error_exit(msg)
upload.ErrorExit = trap_http_500
- maxtries = 40
- for retry in xrange(maxtries):
+ for retry in xrange(self._maxtries):
try:
logging.debug('%s' % request_path)
result = self.rpc_server.Send(request_path, **kwargs)
@@ -422,7 +423,7 @@ class Rietveld(object):
# How nice.
return result
except urllib2.HTTPError, e:
- if retry >= (maxtries - 1):
+ if retry >= (self._maxtries - 1):
raise
flake_codes = [500, 502, 503]
if retry_on_404:
@@ -430,14 +431,14 @@ class Rietveld(object):
if e.code not in flake_codes:
raise
except urllib2.URLError, e:
- if retry >= (maxtries - 1):
+ if retry >= (self._maxtries - 1):
raise
if (not 'Name or service not known' in e.reason and
not 'EOF occurred in violation of protocol' in e.reason):
# Usually internal GAE flakiness.
raise
except ssl.SSLError, e:
- if retry >= (maxtries - 1):
+ if retry >= (self._maxtries - 1):
raise
if not 'timed out' in str(e):
raise
@@ -575,7 +576,8 @@ class JwtOAuth2Rietveld(Rietveld):
client_email,
client_private_key_file,
private_key_password=None,
- extra_headers=None):
+ extra_headers=None,
+ maxtries=None):
# These attributes are accessed by commit queue. Keep them.
self.email = client_email
@@ -598,6 +600,8 @@ class JwtOAuth2Rietveld(Rietveld):
self._xsrf_token = None
self._xsrf_token_time = None
+ self._maxtries = 40 or maxtries
Michael Achenbach 2015/02/19 11:20:33 Hmm, sad that there's no super call.
Jens Widell 2015/02/19 11:32:39 This is the same as "self._maxtries = 40". Did you
Michael Achenbach 2015/02/19 11:33:56 Ups, totally missed that. Good catch!
Paweł Hajdan Jr. 2015/02/19 11:49:04 Good catch, fixed in https://codereview.chromium.o
+
class CachingRietveld(Rietveld):
"""Caches the common queries.
« 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