Add timeout on downloads and --timeout option
Default timeout is 1 minute per mirror.
This commit is contained in:
parent
03cba28315
commit
265b77f365
@ -226,7 +226,7 @@ def get_default_cache():
|
|||||||
return os.path.join(home, ".cache", "hererocks")
|
return os.path.join(home, ".cache", "hererocks")
|
||||||
|
|
||||||
def download(url, filename):
|
def download(url, filename):
|
||||||
response = urlopen(url)
|
response = urlopen(url, timeout=opts.timeout)
|
||||||
data = response.read()
|
data = response.read()
|
||||||
|
|
||||||
with open(filename, "wb") as out:
|
with open(filename, "wb") as out:
|
||||||
@ -527,7 +527,7 @@ class Program(object):
|
|||||||
print("Fetching {} (cached)".format(self.title))
|
print("Fetching {} (cached)".format(self.title))
|
||||||
else:
|
else:
|
||||||
for base_url in self.downloads:
|
for base_url in self.downloads:
|
||||||
url = self.get_download_url()
|
url = self.get_download_url(base_url)
|
||||||
print("Fetching {} from {}".format(self.title, url))
|
print("Fetching {} from {}".format(self.title, url))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1821,6 +1821,9 @@ def main(argv=None):
|
|||||||
default=get_default_lua_target())
|
default=get_default_lua_target())
|
||||||
parser.add_argument("--no-readline", help="Don't use readline library when building standard Lua.",
|
parser.add_argument("--no-readline", help="Don't use readline library when building standard Lua.",
|
||||||
action="store_true", default=False)
|
action="store_true", default=False)
|
||||||
|
parser.add_argument("--timeout",
|
||||||
|
help="Download timeout in seconds.",
|
||||||
|
type=int, default=60)
|
||||||
parser.add_argument("--downloads",
|
parser.add_argument("--downloads",
|
||||||
help="Cache downloads and default git repos in 'DOWNLOADS' directory.",
|
help="Cache downloads and default git repos in 'DOWNLOADS' directory.",
|
||||||
default=get_default_cache())
|
default=get_default_cache())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user