Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_essenv.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_essenv
on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]

permissions:
contents: read
Expand Down
24 changes: 15 additions & 9 deletions scripts/ess.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
import sys
import time
import urllib.parse
import urllib.request
from concurrent.futures import ThreadPoolExecutor
Expand All @@ -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


Expand Down
Loading