summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Kuhn <michael.kuhn@informatik.uni-hamburg.de>2020-02-26 07:45:33 +0100
committerPeter Scheibel <scheibel1@llnl.gov>2020-02-27 10:52:52 -0800
commitf580b340f8fa04a7f2e915e27857ff8dad39aa67 (patch)
treef5e6362211f5906e1fa2578395ebbb7054de7f23 /lib
parentb7cfd05ef72f26524a35c983067cedcc9f3750f3 (diff)
downloadspack-f580b340f8fa04a7f2e915e27857ff8dad39aa67.tar.gz
spack-f580b340f8fa04a7f2e915e27857ff8dad39aa67.tar.bz2
spack-f580b340f8fa04a7f2e915e27857ff8dad39aa67.tar.xz
spack-f580b340f8fa04a7f2e915e27857ff8dad39aa67.zip
Add new timeout fetch_option
This allows packages to override the global connect_timeout.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 40d8b00728..4ca6a886d4 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -329,12 +329,6 @@ class URLFetchStrategy(FetchStrategy):
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 @@ class URLFetchStrategy(FetchStrategy):
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 @@ class URLFetchStrategy(FetchStrategy):
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):