Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c72a9e

Browse files
khancyrpeterbarker
authored andcommitted
update.py: do download in parallele
1 parent 893ad38 commit 8c72a9e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

update.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import subprocess
4949
import sys
5050
import time
51-
from concurrent.futures import ThreadPoolExecutor
51+
from concurrent.futures import ThreadPoolExecutor, TimeoutError
5252
from datetime import datetime
5353
from typing import Dict, List, Optional
5454
from urllib.parse import urlparse
@@ -342,8 +342,18 @@ def fetch_ardupilot_generated_data(site_mapping: Dict, base_url: str, sub_url: s
342342
targetfiles.append(targetfile)
343343
names.append(f"{value}_{document_name}")
344344

345-
with ThreadPoolExecutor() as executor:
346-
executor.map(fetch_and_rename, urls, targetfiles, names, timeout=5*60)
345+
with ThreadPoolExecutor(max_workers=4) as executor: # Limit concurrent downloads
346+
tasks = []
347+
for url, target, name in zip(urls, targetfiles, names):
348+
task = executor.submit(fetch_and_rename, url, target, name)
349+
tasks.append(task)
350+
351+
# Wait for all downloads to complete
352+
for task in tasks:
353+
try:
354+
task.result(timeout=5*60)
355+
except (TimeoutError, OSError, requests.RequestException) as e:
356+
error(f"Download failed: {e}")
347357

348358

349359
def build_one(wiki, fast):

0 commit comments

Comments
 (0)