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

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: Add explicit conversion for better error messages. 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:
686 except urllib2.URLError as e:
687 if i + 1 == tries:
688 raise 687 raise
689 else: 688 else:
690 print "Cannot GET %s: %s" % (url, e) 689 print "Cannot GET %s: %s" % (url, str(e))
690 except urllib2.URLError as e:
691 if i + 1 >= tries:
692 raise
693 else:
694 print "Cannot GET %s: %s" % (url, str(e))
695 print "Sleeping for 10 seconds before retrying..."
696 time.sleep(10)
691 697
692 url = os.path.join(binhost_url, "Packages") 698 url = os.path.join(binhost_url, "Packages")
693 try: 699 try:
694 f = retry_urlopen(url) 700 f = retry_urlopen(url)
695 except urllib2.HTTPError as e: 701 except urllib2.HTTPError as e:
696 if e.code == 404: 702 if e.code == 404:
697 return {} 703 return {}
698 else: 704 else:
699 raise 705 raise
700 prebuilt_pkgs = {} 706 prebuilt_pkgs = {}
(...skipping 1129 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. 1836 # need to upgrade the rest of the packages. So we'll go ahead and do that.
1831 if portage_upgrade: 1837 if portage_upgrade:
1832 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] 1838 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"]
1833 os.execvp(os.path.realpath(sys.argv[0]), args) 1839 os.execvp(os.path.realpath(sys.argv[0]), args)
1834 1840
1835 print "Done" 1841 print "Done"
1836 sys.exit(0) 1842 sys.exit(0)
1837 1843
1838 if __name__ == "__main__": 1844 if __name__ == "__main__":
1839 main() 1845 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