Browse Source

download_hash: use persistent session

This allows to reuse http connection and be more efficient.
From rough measuring it saves around 25-30% of execution time.
pull/11513/head
Max Gautier 2 months ago
parent
commit
1b1045c0e2
Failed to extract signature
1 changed files with 2 additions and 1 deletions
  1. 3
      scripts/download_hash.py

3
scripts/download_hash.py

@ -98,6 +98,7 @@ def download_hash(only_downloads: [str]) -> None:
} }
data, yaml = open_checksums_yaml() data, yaml = open_checksums_yaml()
s = requests.Session()
for download, url in (downloads if only_downloads == [] for download, url in (downloads if only_downloads == []
else {k:downloads[k] for k in downloads.keys() & only_downloads}).items(): else {k:downloads[k] for k in downloads.keys() & only_downloads}).items():
@ -124,7 +125,7 @@ def download_hash(only_downloads: [str]) -> None:
# to find new versions # to find new versions
if version in versions and versions[version] != 0: if version in versions and versions[version] != 0:
continue continue
hash_file = requests.get(downloads[download].format(
hash_file = s.get(downloads[download].format(
version = version, version = version,
os = "linux", os = "linux",
arch = arch arch = arch

Loading…
Cancel
Save