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

Side by Side Diff: parallel_emerge

Issue 5056003: Retry in parallel_emerge for 5xx error codes. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Created 10 years, 1 month 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/python2.6 1 #!/usr/bin/python2.6
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS 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 """Program to run emerge in parallel, for significant speedup. 6 """Program to run emerge in parallel, for significant speedup.
7 7
8 Usage: 8 Usage:
9 ./parallel_emerge [--board=BOARD] [--workon=PKGS] [--no-workon-deps] 9 ./parallel_emerge [--board=BOARD] [--workon=PKGS] [--no-workon-deps]
10 [--force-remote-binary=PKGS] [emerge args] package 10 [--force-remote-binary=PKGS] [emerge args] package
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 binhost_url: Base URL of remote packages (PORTAGE_BINHOST). 660 binhost_url: Base URL of remote packages (PORTAGE_BINHOST).
661 661
662 Returns: 662 Returns:
663 A dict mapping package identifiers to modification times. 663 A dict mapping package identifiers to modification times.
664 """ 664 """
665 665
666 if not binhost_url: 666 if not binhost_url:
667 return {} 667 return {}
668 668
669 def retry_urlopen(url, tries=3): 669 def retry_urlopen(url, tries=3):
670 """Open the specified url, retrying if we run into network errors. 670 """Open the specified url, retrying if we run into temporary errors.
671 671
672 We do not retry for HTTP errors. 672 We retry for both network errors and 5xx Server Errors. We do not retry
673 for HTTP errors with a non-5xx code.
673 674
674 Args: 675 Args:
675 url: The specified url. 676 url: The specified url.
676 tries: The number of times to try. 677 tries: The number of times to try.
677 678
678 Returns: 679 Returns:
679 The result of urllib2.urlopen(url). 680 The result of urllib2.urlopen(url).
680 """ 681 """
681 for i in range(tries): 682 for i in range(tries):
682 try: 683 try:
683 return urllib2.urlopen(url) 684 return urllib2.urlopen(url)
684 except urllib2.HTTPError as e: 685 except urllib2.HTTPError as e:
685 raise 686 if i + 1 == tries or e.code < 500:
sosa 2010/11/16 18:09:25 use >= in case
687 raise
688 else:
689 print "Cannot GET %s: %s" % (url, e)
sosa 2010/11/16 18:09:25 Adding a retrying message and you should probably
686 except urllib2.URLError as e: 690 except urllib2.URLError as e:
687 if i + 1 == tries: 691 if i + 1 == tries:
688 raise 692 raise
689 else: 693 else:
690 print "Cannot GET %s: %s" % (url, e) 694 print "Cannot GET %s: %s" % (url, e)
691 695
692 url = os.path.join(binhost_url, "Packages") 696 url = os.path.join(binhost_url, "Packages")
693 try: 697 try:
694 f = retry_urlopen(url) 698 f = retry_urlopen(url)
695 except urllib2.HTTPError as e: 699 except urllib2.HTTPError as e:
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 # need to upgrade the rest of the packages. So we'll go ahead and do that. 1834 # need to upgrade the rest of the packages. So we'll go ahead and do that.
1831 if portage_upgrade: 1835 if portage_upgrade:
1832 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] 1836 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"]
1833 os.execvp(os.path.realpath(sys.argv[0]), args) 1837 os.execvp(os.path.realpath(sys.argv[0]), args)
1834 1838
1835 print "Done" 1839 print "Done"
1836 sys.exit(0) 1840 sys.exit(0)
1837 1841
1838 if __name__ == "__main__": 1842 if __name__ == "__main__":
1839 main() 1843 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