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

Side by Side Diff: scripts/slave/bot_update.py

Issue 1254753002: Add exponential backoff to bot_update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Better checks, add jitter. Created 5 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import copy 11 import copy
12 import ctypes 12 import ctypes
13 import json 13 import json
14 import optparse 14 import optparse
15 import os 15 import os
16 import pprint 16 import pprint
17 import random
17 import re 18 import re
18 import socket 19 import socket
19 import subprocess 20 import subprocess
20 import sys 21 import sys
21 import tempfile 22 import tempfile
22 import time 23 import time
23 import urllib2 24 import urllib2
24 import urlparse 25 import urlparse
25 import uuid 26 import uuid
26 27
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 result = result_fn(code, outval) 409 result = result_fn(code, outval)
409 if result in (FAIL, RETRY): 410 if result in (FAIL, RETRY):
410 print '===Failed in %.1f mins===' % elapsed_time 411 print '===Failed in %.1f mins===' % elapsed_time
411 print 412 print
412 else: 413 else:
413 print '===Succeeded in %.1f mins===' % elapsed_time 414 print '===Succeeded in %.1f mins===' % elapsed_time
414 print 415 print
415 return outval 416 return outval
416 if result is FAIL: 417 if result is FAIL:
417 break 418 break
419 if result is RETRY:
420 sleep_backoff = 4 ** attempt
421 sleep_time = random.randint(sleep_backoff, int(sleep_backoff * 1.2))
422 print '===backing off, sleeping for %ds===' % sleep_time
agable 2015/07/24 02:48:17 I'm scared that "%ds" is a format thing. Maybe do
ghost stip (do not use) 2015/07/24 02:50:16 done
423 time.sleep(sleep_time)
418 424
419 raise SubprocessFailed('%s failed with code %d in %s after %d attempts.' % 425 raise SubprocessFailed('%s failed with code %d in %s after %d attempts.' %
420 (' '.join(args), code, cwd, attempt), 426 (' '.join(args), code, cwd, attempt),
421 code, outval) 427 code, outval)
422 428
423 429
424 def git(*args, **kwargs): # pragma: no cover 430 def git(*args, **kwargs): # pragma: no cover
425 """Wrapper around call specifically for Git commands.""" 431 """Wrapper around call specifically for Git commands."""
426 if args and args[0] == 'cache': 432 if args and args[0] == 'cache':
427 # Rewrite "git cache" calls into "python git_cache.py". 433 # Rewrite "git cache" calls into "python git_cache.py".
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 except Exception: 1625 except Exception:
1620 # Unexpected failure. 1626 # Unexpected failure.
1621 emit_flag(options.flag_file) 1627 emit_flag(options.flag_file)
1622 raise 1628 raise
1623 else: 1629 else:
1624 emit_flag(options.flag_file) 1630 emit_flag(options.flag_file)
1625 1631
1626 1632
1627 if __name__ == '__main__': 1633 if __name__ == '__main__':
1628 sys.exit(main()) 1634 sys.exit(main())
OLDNEW
« 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