test/infamy: catch TimeoutError in curl() to allow retries

Python's urllib.request wraps OSError in URLError during the connection
phase, but NOT during response reading (getresponse()).  This means a
timeout that fires after the TCP handshake completes, e.g. when a service
accepts the connection but hasn't sent a response yet, propagates as a
bare TimeoutError that bypasses the exception handler, killing the entire
until() retry loop on the first attempt.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-02-26 13:43:41 +01:00
parent 4522d9f217
commit b5a292d7dd
+1 -1
View File
@@ -116,7 +116,7 @@ def curl(url, timeout=10, silent=False):
try:
with urllib.request.urlopen(url, timeout=timeout) as response:
return response.read().decode('utf-8', errors='replace')
except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError) as e:
except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError, TimeoutError) as e:
if not silent:
print(f"[WARN] curl: failed to fetch {url}: {e}")
return ""