From ccf8f164cfb12f8ba930f1a43060fbb801321178 Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Thu, 26 Sep 2024 00:23:10 +0300 Subject: [PATCH] Retry downloading Winbindex json.gz files --- scripts/02_download_binaries.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/02_download_binaries.py b/scripts/02_download_binaries.py index 279e23834..66e79f7d4 100644 --- a/scripts/02_download_binaries.py +++ b/scripts/02_download_binaries.py @@ -5,6 +5,7 @@ import shutil import subprocess import tempfile +import time from argparse import ArgumentParser from datetime import datetime from pathlib import Path @@ -80,8 +81,20 @@ def download_binaries_from_symbol_server(name: str, target_folder: Path, previou else: url = f'https://winbindex.m417z.com/data/by_filename_compressed/{name}.json.gz' - r = requests.get(url) - r.raise_for_status() + while True: + try: + r = requests.get(url) + if 500 <= r.status_code < 600: + raise Exception(f'Server Error: {r.status_code} for url: {url}') + break + except Exception as e: + print(f'ERROR: failed to get {url}, retrying in 10 seconds') + print(f' {e}') + time.sleep(10) + + if 400 <= r.status_code < 500: + raise Exception(f'Client Error: {r.status_code} for url: {url}') + data_compressed = r.content data_json_str = gzip.decompress(data_compressed).decode() data = json.loads(data_json_str)