Add new timeout fetch_option

This allows packages to override the global connect_timeout.
This commit is contained in:
Michael Kuhn
2020-02-26 07:45:33 +01:00
committed by Peter Scheibel
parent b7cfd05ef7
commit f580b340f8
3 changed files with 21 additions and 10 deletions

View File

@@ -329,12 +329,6 @@ def _fetch_from_url(self, url):
url,
]
connect_timeout = spack.config.get('config:connect_timeout')
if connect_timeout > 0:
# Timeout if can't establish a connection after n sec.
curl_args.extend(['--connect-timeout', str(connect_timeout)])
if not spack.config.get('config:verify_ssl'):
curl_args.append('-k')
@@ -343,6 +337,8 @@ def _fetch_from_url(self, url):
else:
curl_args.append('-sS') # just errors when not.
connect_timeout = spack.config.get('config:connect_timeout')
if self.extra_options:
cookie = self.extra_options.get('cookie')
if cookie:
@@ -350,6 +346,14 @@ def _fetch_from_url(self, url):
curl_args.append('-b') # specify cookie
curl_args.append(cookie)
timeout = self.extra_options.get('timeout')
if timeout:
connect_timeout = max(connect_timeout, int(timeout))
if connect_timeout > 0:
# Timeout if can't establish a connection after n sec.
curl_args.extend(['--connect-timeout', str(connect_timeout)])
# Run curl but grab the mime type from the http headers
curl = self.curl
with working_dir(self.stage.path):