Increase download timeout to 20s

This commit is contained in:
oobabooga 2023-06-08 11:16:38 -03:00
parent 878250d609
commit 240752617d

View File

@ -108,7 +108,7 @@ class ModelDownloader:
is_lora = False is_lora = False
while True: while True:
url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "") url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
r = self.s.get(url, timeout=10) r = self.s.get(url, timeout=20)
r.raise_for_status() r.raise_for_status()
content = r.content content = r.content
@ -180,7 +180,7 @@ class ModelDownloader:
output_path = output_folder / filename output_path = output_folder / filename
if output_path.exists() and not start_from_scratch: if output_path.exists() and not start_from_scratch:
# Check if the file has already been downloaded completely # Check if the file has already been downloaded completely
r = self.s.get(url, stream=True, timeout=10) r = self.s.get(url, stream=True, timeout=20)
total_size = int(r.headers.get('content-length', 0)) total_size = int(r.headers.get('content-length', 0))
if output_path.stat().st_size >= total_size: if output_path.stat().st_size >= total_size:
return return
@ -191,7 +191,7 @@ class ModelDownloader:
headers = {} headers = {}
mode = 'wb' mode = 'wb'
r = self.s.get(url, stream=True, headers=headers, timeout=10) r = self.s.get(url, stream=True, headers=headers, timeout=20)
with open(output_path, mode) as f: with open(output_path, mode) as f:
total_size = int(r.headers.get('content-length', 0)) total_size = int(r.headers.get('content-length', 0))
block_size = 1024 block_size = 1024