fetch_assets: use more threads and increase the read timeout a bit

bumping the thread count makes things a bit faster here, and to not hit
a read timeout, increase that a bit as well.
This commit is contained in:
Christoph Reiter 2020-12-01 19:16:15 +01:00
parent 68a4ac86cc
commit 0c0d36fbdc

View File

@ -95,9 +95,9 @@ def asset_is_complete(asset: GitReleaseAsset) -> bool:
return asset.state == "uploaded" return asset.state == "uploaded"
def download_asset(asset: GitReleaseAsset, target_path: str, timeout: int = 15) -> None: def download_asset(asset: GitReleaseAsset, target_path: str) -> None:
assert asset_is_complete(asset) assert asset_is_complete(asset)
with requests.get(asset.browser_download_url, stream=True, timeout=timeout) as r: with requests.get(asset.browser_download_url, stream=True, timeout=(15, 30)) as r:
r.raise_for_status() r.raise_for_status()
fd, temppath = tempfile.mkstemp() fd, temppath = tempfile.mkstemp()
try: try:
@ -656,7 +656,7 @@ def fetch_assets(args: Any) -> None:
download_asset(asset, asset_path) download_asset(asset, asset_path)
return item return item
with ThreadPoolExecutor(4) as executor: with ThreadPoolExecutor(8) as executor:
for i, item in enumerate(executor.map(fetch_item, todo)): for i, item in enumerate(executor.map(fetch_item, todo)):
print(f"[{i + 1}/{len(todo)}] {get_asset_filename(item[0])}") print(f"[{i + 1}/{len(todo)}] {get_asset_filename(item[0])}")