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

Unified Diff: parallel_emerge

Issue 3473017: Update parallel_emerge to retry when we encounter DNS errors. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: parallel_emerge
diff --git a/parallel_emerge b/parallel_emerge
index 03684c2ed0d702685d95c46a0c33e53d46250b44..61e9920efb08e427ec1dd32ad2bba8dccdace3e4 100755
--- a/parallel_emerge
+++ b/parallel_emerge
@@ -924,16 +924,38 @@ class DepGraphGenerator(object):
if not binhost_url:
return {}
- url = binhost_url + "/Packages"
+ def retry_urlopen(url, tries=3):
+ """Open the specified url, retrying if we run into network errors.
- prebuilt_pkgs = {}
+ We do not retry for HTTP errors.
+
+ Args:
+ url: The specified url.
+ tries: The number of times to try.
+
+ Returns:
+ The result of urllib2.urlopen(url).
+ """
+ for i in range(tries):
+ try:
+ return urllib2.urlopen(url)
+ except urllib2.HTTPError as e:
+ raise
+ except urllib2.URLError as e:
+ if i + 1 == tries:
+ raise
+ else:
+ print "Cannot GET %s: %s" % (url, e)
+
+ url = binhost_url + "/Packages"
try:
- f = urllib2.urlopen(url)
+ f = retry_urlopen(url)
except urllib2.HTTPError as e:
if e.code == 404:
return {}
else:
raise
+ prebuilt_pkgs = {}
for line in f:
if line.startswith("CPV: "):
pkg = line.replace("CPV: ", "").rstrip()
@@ -1144,7 +1166,8 @@ class DepGraphGenerator(object):
local_pkgs = LocalPackageDatabase()
remote_pkgs = {}
if "--getbinpkg" in emerge.opts:
- remote_pkgs = RemotePackageDatabase(emerge.settings["PORTAGE_BINHOST"])
+ binhost = emerge.settings["PORTAGE_BINHOST"]
+ remote_pkgs = RemotePackageDatabase(binhost)
AutoRebuildDeps(local_pkgs, remote_pkgs, cycles)
# We need to remove installed packages so that we can use the dependency
« 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