Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 | 5 |
| 6 # TODO(hinoka): Use logging. | 6 # TODO(hinoka): Use logging. |
| 7 | 7 |
| 8 import cStringIO | 8 import cStringIO |
| 9 import codecs | 9 import codecs |
| 10 import collections | 10 import collections |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 result = result_fn(code, outval) | 408 result = result_fn(code, outval) |
| 409 if result in (FAIL, RETRY): | 409 if result in (FAIL, RETRY): |
| 410 print '===Failed in %.1f mins===' % elapsed_time | 410 print '===Failed in %.1f mins===' % elapsed_time |
| 411 print | 411 print |
| 412 else: | 412 else: |
| 413 print '===Succeeded in %.1f mins===' % elapsed_time | 413 print '===Succeeded in %.1f mins===' % elapsed_time |
| 414 print | 414 print |
| 415 return outval | 415 return outval |
| 416 if result is FAIL: | 416 if result is FAIL: |
| 417 break | 417 break |
| 418 if attempt > 0: | |
|
agable
2015/07/24 02:37:22
attempt is always > 0, it starts at 1. I think you
| |
| 419 sleep_time = 4 ** attempt | |
|
agable
2015/07/24 02:37:22
jitter by +/- 20%?
| |
| 420 print '===backing off, sleeping for %ds===' % sleep_time | |
| 421 time.sleep(sleep_time) | |
| 418 | 422 |
| 419 raise SubprocessFailed('%s failed with code %d in %s after %d attempts.' % | 423 raise SubprocessFailed('%s failed with code %d in %s after %d attempts.' % |
| 420 (' '.join(args), code, cwd, attempt), | 424 (' '.join(args), code, cwd, attempt), |
| 421 code, outval) | 425 code, outval) |
| 422 | 426 |
| 423 | 427 |
| 424 def git(*args, **kwargs): # pragma: no cover | 428 def git(*args, **kwargs): # pragma: no cover |
| 425 """Wrapper around call specifically for Git commands.""" | 429 """Wrapper around call specifically for Git commands.""" |
| 426 if args and args[0] == 'cache': | 430 if args and args[0] == 'cache': |
| 427 # Rewrite "git cache" calls into "python git_cache.py". | 431 # Rewrite "git cache" calls into "python git_cache.py". |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1619 except Exception: | 1623 except Exception: |
| 1620 # Unexpected failure. | 1624 # Unexpected failure. |
| 1621 emit_flag(options.flag_file) | 1625 emit_flag(options.flag_file) |
| 1622 raise | 1626 raise |
| 1623 else: | 1627 else: |
| 1624 emit_flag(options.flag_file) | 1628 emit_flag(options.flag_file) |
| 1625 | 1629 |
| 1626 | 1630 |
| 1627 if __name__ == '__main__': | 1631 if __name__ == '__main__': |
| 1628 sys.exit(main()) | 1632 sys.exit(main()) |
| OLD | NEW |