From 1b1045c0e2f1a472aee625b78765c453be78eb13 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Fri, 6 Sep 2024 15:25:53 +0200 Subject: [PATCH] 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. --- scripts/download_hash.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/download_hash.py b/scripts/download_hash.py index 77ba34e82..53397c76d 100644 --- a/scripts/download_hash.py +++ b/scripts/download_hash.py @@ -98,6 +98,7 @@ def download_hash(only_downloads: [str]) -> None: } data, yaml = open_checksums_yaml() + s = requests.Session() for download, url in (downloads if only_downloads == [] 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 if version in versions and versions[version] != 0: continue - hash_file = requests.get(downloads[download].format( + hash_file = s.get(downloads[download].format( version = version, os = "linux", arch = arch