mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
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:
+1
-1
@@ -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 ""
|
||||
Reference in New Issue
Block a user