mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-18 09:02:04 +01:00
Update parallel_emerge to retry when we encounter DNS errors.
BUG=chromium-os:7049 TEST=Tested that DNS errors are retried. Also tested that 404 errors are not retried. Change-Id: I0f38764e7af822f7db554697b9fa84af033bf111 Review URL: http://codereview.chromium.org/3473017
This commit is contained in:
parent
358b738f63
commit
1a6b812cf0
@ -924,16 +924,38 @@ class DepGraphGenerator(object):
|
|||||||
if not binhost_url:
|
if not binhost_url:
|
||||||
return {}
|
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:
|
try:
|
||||||
f = urllib2.urlopen(url)
|
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 = retry_urlopen(url)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
prebuilt_pkgs = {}
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("CPV: "):
|
if line.startswith("CPV: "):
|
||||||
pkg = line.replace("CPV: ", "").rstrip()
|
pkg = line.replace("CPV: ", "").rstrip()
|
||||||
@ -1144,7 +1166,8 @@ class DepGraphGenerator(object):
|
|||||||
local_pkgs = LocalPackageDatabase()
|
local_pkgs = LocalPackageDatabase()
|
||||||
remote_pkgs = {}
|
remote_pkgs = {}
|
||||||
if "--getbinpkg" in emerge.opts:
|
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)
|
AutoRebuildDeps(local_pkgs, remote_pkgs, cycles)
|
||||||
|
|
||||||
# We need to remove installed packages so that we can use the dependency
|
# We need to remove installed packages so that we can use the dependency
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user