Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 """Defines class Rietveld to easily access a rietveld instance. | 5 """Defines class Rietveld to easily access a rietveld instance. |
| 6 | 6 |
| 7 Security implications: | 7 Security implications: |
| 8 | 8 |
| 9 The following hypothesis are made: | 9 The following hypothesis are made: |
| 10 - Rietveld enforces: | 10 - Rietveld enforces: |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 def trap_http_500(msg): | 402 def trap_http_500(msg): |
| 403 """Converts an incorrect ErrorExit() call into a HTTPError exception.""" | 403 """Converts an incorrect ErrorExit() call into a HTTPError exception.""" |
| 404 m = re.search(r'(50\d) Server Error', msg) | 404 m = re.search(r'(50\d) Server Error', msg) |
| 405 if m: | 405 if m: |
| 406 # Fake an HTTPError exception. Cheezy. :( | 406 # Fake an HTTPError exception. Cheezy. :( |
| 407 raise urllib2.HTTPError( | 407 raise urllib2.HTTPError( |
| 408 request_path, int(m.group(1)), msg, None, None) | 408 request_path, int(m.group(1)), msg, None, None) |
| 409 old_error_exit(msg) | 409 old_error_exit(msg) |
| 410 upload.ErrorExit = trap_http_500 | 410 upload.ErrorExit = trap_http_500 |
| 411 | 411 |
| 412 maxtries = 5 | 412 maxtries = 40 |
| 413 for retry in xrange(maxtries): | 413 for retry in xrange(maxtries): |
| 414 try: | 414 try: |
| 415 logging.debug('%s' % request_path) | 415 logging.debug('%s' % request_path) |
| 416 result = self.rpc_server.Send(request_path, **kwargs) | 416 result = self.rpc_server.Send(request_path, **kwargs) |
| 417 # Sometimes GAE returns a HTTP 200 but with HTTP 500 as the content. | 417 # Sometimes GAE returns a HTTP 200 but with HTTP 500 as the content. |
| 418 # How nice. | 418 # How nice. |
| 419 return result | 419 return result |
| 420 except urllib2.HTTPError, e: | 420 except urllib2.HTTPError, e: |
| 421 if retry >= (maxtries - 1): | 421 if retry >= (maxtries - 1): |
| 422 raise | 422 raise |
| 423 if e.code not in (500, 502, 503): | 423 if e.code not in (500, 502, 503): |
| 424 raise | 424 raise |
| 425 except urllib2.URLError, e: | 425 except urllib2.URLError, e: |
| 426 if retry >= (maxtries - 1): | 426 if retry >= (maxtries - 1): |
| 427 raise | 427 raise |
| 428 if (not 'Name or service not known' in e.reason and | 428 if (not 'Name or service not known' in e.reason and |
| 429 not 'EOF occurred in violation of protocol' in e.reason): | 429 not 'EOF occurred in violation of protocol' in e.reason): |
| 430 # Usually internal GAE flakiness. | 430 # Usually internal GAE flakiness. |
| 431 raise | 431 raise |
| 432 except ssl.SSLError, e: | 432 except ssl.SSLError, e: |
| 433 if retry >= (maxtries - 1): | 433 if retry >= (maxtries - 1): |
| 434 raise | 434 raise |
| 435 if not 'timed out' in str(e): | 435 if not 'timed out' in str(e): |
| 436 raise | 436 raise |
| 437 # If reaching this line, loop again. Uses a small backoff. | 437 # If reaching this line, loop again. Uses a small backoff. |
| 438 time.sleep(1+maxtries*2) | 438 time.sleep(10) |
|
M-A Ruel
2014/06/13 15:42:55
Please replace with:
time.sleep(min(10, 1+maxtrie
Sergiy Byelozyorov
2014/06/13 17:02:16
Done.
| |
| 439 finally: | 439 finally: |
| 440 upload.ErrorExit = old_error_exit | 440 upload.ErrorExit = old_error_exit |
| 441 | 441 |
| 442 # DEPRECATED. | 442 # DEPRECATED. |
| 443 Send = get | 443 Send = get |
| 444 | 444 |
| 445 | 445 |
| 446 class OAuthRpcServer(object): | 446 class OAuthRpcServer(object): |
| 447 def __init__(self, | 447 def __init__(self, |
| 448 host, | 448 host, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 def trigger_try_jobs( # pylint:disable=R0201 | 717 def trigger_try_jobs( # pylint:disable=R0201 |
| 718 self, issue, patchset, reason, clobber, revision, builders_and_tests, | 718 self, issue, patchset, reason, clobber, revision, builders_and_tests, |
| 719 master=None): | 719 master=None): |
| 720 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 720 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 721 (builders_and_tests, issue)) | 721 (builders_and_tests, issue)) |
| 722 | 722 |
| 723 def trigger_distributed_try_jobs( # pylint:disable=R0201 | 723 def trigger_distributed_try_jobs( # pylint:disable=R0201 |
| 724 self, issue, patchset, reason, clobber, revision, masters): | 724 self, issue, patchset, reason, clobber, revision, masters): |
| 725 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 725 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
| 726 (masters, issue)) | 726 (masters, issue)) |
| OLD | NEW |