From f580b340f8fa04a7f2e915e27857ff8dad39aa67 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Wed, 26 Feb 2020 07:45:33 +0100 Subject: Add new timeout fetch_option This allows packages to override the global connect_timeout. --- lib/spack/spack/fetch_strategy.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib') 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): -- cgit v1.2.3-70-g09d2