From d8a76b4116b69b7f25574b3af86fd0f8aec925ae Mon Sep 17 00:00:00 2001 From: "zhengxin.1999" Date: Wed, 31 Aug 2022 17:27:14 +0800 Subject: [PATCH 1/2] enable http request retry under proxy --- src/huggingface_hub/file_download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/huggingface_hub/file_download.py b/src/huggingface_hub/file_download.py index 929c638e18..34d0c8b1c3 100644 --- a/src/huggingface_hub/file_download.py +++ b/src/huggingface_hub/file_download.py @@ -461,7 +461,7 @@ def _request_wrapper( method=method.upper(), url=url, timeout=timeout, **params ) success = True - except requests.exceptions.ConnectTimeout as err: + except (requests.exceptions.ConnectTimeout, requests.exceptions.ProxyError) as err: # or simply "except Exception as err:" if tries > max_retries: raise err else: From e84faef85712aac8ee2444803a7394fde4109999 Mon Sep 17 00:00:00 2001 From: Lucain Date: Wed, 31 Aug 2022 12:12:11 +0200 Subject: [PATCH 2/2] Update src/huggingface_hub/file_download.py --- src/huggingface_hub/file_download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/huggingface_hub/file_download.py b/src/huggingface_hub/file_download.py index 34d0c8b1c3..d682cbd3b3 100644 --- a/src/huggingface_hub/file_download.py +++ b/src/huggingface_hub/file_download.py @@ -461,7 +461,10 @@ def _request_wrapper( method=method.upper(), url=url, timeout=timeout, **params ) success = True - except (requests.exceptions.ConnectTimeout, requests.exceptions.ProxyError) as err: # or simply "except Exception as err:" + except ( + requests.exceptions.ConnectTimeout, + requests.exceptions.ProxyError, + ) as err: if tries > max_retries: raise err else: