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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 if retry >= (self._maxtries - 1): | 424 if retry >= (self._maxtries - 1): |
425 raise | 425 raise |
426 flake_codes = [500, 502, 503] | 426 flake_codes = [500, 502, 503] |
427 if retry_on_404: | 427 if retry_on_404: |
428 flake_codes.append(404) | 428 flake_codes.append(404) |
429 if e.code not in flake_codes: | 429 if e.code not in flake_codes: |
430 raise | 430 raise |
431 except urllib2.URLError, e: | 431 except urllib2.URLError, e: |
432 if retry >= (self._maxtries - 1): | 432 if retry >= (self._maxtries - 1): |
433 raise | 433 raise |
434 if (not 'Name or service not known' in e.reason and | 434 |
435 not 'EOF occurred in violation of protocol' in e.reason and | 435 def is_transient(): |
436 not 'timed out' in e.reason and | 436 # The idea here is to retry if the error isn't permanent. |
437 not 'The handshake operation timed out' in e.reason and | 437 # Unfortunately, there are so many different possible errors, |
438 # On windows we hit weird bug http://crbug.com/537417 | 438 # that we end up enumerating those that are known to us to be |
439 # with message '[Errno 10060] A connection attempt failed...' | 439 # transient. |
440 not (sys.platform.startswith('win') and | 440 # The reason can be a string or another exception, e.g., |
441 isinstance(e.reason, socket.error) and | 441 # socket.error or whatever else. |
442 e.reason.errno == errno.ETIMEDOUT | 442 reason_as_str = str(e.reason) |
443 ) | 443 for retry_anyway in [ |
Sergiy Byelozyorov
2015/12/03 14:54:45
return any(str in reason_as_str for str in [...]):
tandrii(chromium)
2015/12/03 14:58:27
I found "str in" for "str in" confusing, even thou
| |
444 ): | 444 'Name or service not known', |
445 # Usually internal GAE flakiness. | 445 'EOF occurred in violation of protocol', |
446 'The handshake operation timed out', | |
Adrian Kuegel
2015/12/03 14:53:31
Drive-by: this line seems to be redundant.
tandrii(chromium)
2015/12/03 14:58:27
Totally!
| |
447 'timed out']: | |
448 if retry_anyway in reason_as_str: | |
449 return True | |
450 return False # Assume permanent otherwise. | |
451 if not is_transient(): | |
446 raise | 452 raise |
447 except socket.error, e: | 453 except socket.error, e: |
448 if retry >= (self._maxtries - 1): | 454 if retry >= (self._maxtries - 1): |
449 raise | 455 raise |
450 if not 'timed out' in str(e): | 456 if not 'timed out' in str(e): |
451 raise | 457 raise |
452 # If reaching this line, loop again. Uses a small backoff. | 458 # If reaching this line, loop again. Uses a small backoff. |
453 time.sleep(min(10, 1+retry*2)) | 459 time.sleep(min(10, 1+retry*2)) |
454 except urllib2.HTTPError as e: | 460 except urllib2.HTTPError as e: |
455 print 'Request to %s failed: %s' % (e.geturl(), e.read()) | 461 print 'Request to %s failed: %s' % (e.geturl(), e.read()) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
732 self, issue, patchset, reason, clobber, revision, builders_and_tests, | 738 self, issue, patchset, reason, clobber, revision, builders_and_tests, |
733 master=None, category='cq'): | 739 master=None, category='cq'): |
734 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 740 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
735 (builders_and_tests, issue)) | 741 (builders_and_tests, issue)) |
736 | 742 |
737 def trigger_distributed_try_jobs( # pylint:disable=R0201 | 743 def trigger_distributed_try_jobs( # pylint:disable=R0201 |
738 self, issue, patchset, reason, clobber, revision, masters, | 744 self, issue, patchset, reason, clobber, revision, masters, |
739 category='cq'): | 745 category='cq'): |
740 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % | 746 logging.info('ReadOnlyRietveld: triggering try jobs %r for issue %d' % |
741 (masters, issue)) | 747 (masters, issue)) |
OLD | NEW |