File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 33
44from huggingface_hub import HfApi , hf_hub_url
55from packaging import version
6- from requests import HTTPError
6+ from requests import ConnectionError , HTTPError
77
88from .. import config
99from . import logging
@@ -18,15 +18,17 @@ def preupload_lfs_files(hf_api: HfApi, **kwargs):
1818 max_retries = 5
1919 base_wait_time = 1
2020 max_wait_time = 8
21- status_codes = [500 , 503 ]
2221 retry = 0
2322 while True :
2423 try :
2524 hf_api .preupload_lfs_files (** kwargs )
26- except (RuntimeError , HTTPError ) as err :
27- if isinstance (err , RuntimeError ) and isinstance (err .__cause__ , HTTPError ):
28- err = err .__cause__
29- if retry >= max_retries or err .response .status_code not in status_codes :
25+ except (RuntimeError , HTTPError , ConnectionError ) as err :
26+ if isinstance (err , RuntimeError ):
27+ if isinstance (err .__cause__ , (HTTPError , ConnectionError )):
28+ err = err .__cause__
29+ else :
30+ raise err
31+ if retry >= max_retries or err .response and err .response .status_code not in [500 , 503 ]:
3032 raise err
3133 else :
3234 sleep_time = min (max_wait_time , base_wait_time * 2 ** retry ) # Exponential backoff
You can’t perform that action at this time.
0 commit comments