From 5b7c6c5c5c003a6a3dd0640f2468a40ef876b7fe Mon Sep 17 00:00:00 2001 From: WardDeb Date: Wed, 23 Sep 2026 16:28:23 +0200 Subject: [PATCH] URL exists timeout+retry, not on push for ess --- .github/workflows/test_essenv.yml | 2 +- scripts/ess.py | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test_essenv.yml b/.github/workflows/test_essenv.yml index f9aac3f966..d250712f02 100644 --- a/.github/workflows/test_essenv.yml +++ b/.github/workflows/test_essenv.yml @@ -1,5 +1,5 @@ name: test_essenv -on: [push, pull_request, workflow_dispatch] +on: [pull_request, workflow_dispatch] permissions: contents: read diff --git a/scripts/ess.py b/scripts/ess.py index a7002e3d36..8e877ccef7 100644 --- a/scripts/ess.py +++ b/scripts/ess.py @@ -4,6 +4,7 @@ import shutil import subprocess import sys +import time import urllib.parse import urllib.request from concurrent.futures import ThreadPoolExecutor @@ -30,17 +31,22 @@ } TABLE_RE = re.compile(r"^\+(?:[-=]+\+)+\n(?:\|.*\|\n\+(?:[-=]+\+)+\n)+", re.MULTILINE) - +RETRY_ATTEMPTS = 3 +RETRY_DELAY = 90 def url_exists(url: str, timeout: float = 15) -> bool: - for method, headers in (("HEAD", {}), ("GET", {"Range": "bytes=0-0"})): - try: - req = urllib.request.Request(url, method=method, headers=headers) - with urllib.request.urlopen(req, timeout=timeout) as resp: - if 200 <= resp.status < 400: - return True - except Exception: # noqa: S110 - pass + for attempt in range(1, RETRY_ATTEMPTS + 1): + for method, headers in (("HEAD", {}), ("GET", {"Range": "bytes=0-0"})): + try: + req = urllib.request.Request(url, method=method, headers=headers) + with urllib.request.urlopen(req, timeout=timeout) as resp: + if 200 <= resp.status < 400: + return True + except Exception: # noqa: S110 + pass + if attempt < RETRY_ATTEMPTS: + print(f" {url} unreachable (attempt {attempt}/{RETRY_ATTEMPTS}), retrying in {RETRY_DELAY}s") + time.sleep(RETRY_DELAY) return False