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