Skip to content

Commit b5a292d

Browse files
committed
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>
1 parent 4522d9f commit b5a292d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

test/infamy/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def curl(url, timeout=10, silent=False):
116116
try:
117117
with urllib.request.urlopen(url, timeout=timeout) as response:
118118
return response.read().decode('utf-8', errors='replace')
119-
except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError) as e:
119+
except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError, TimeoutError) as e:
120120
if not silent:
121121
print(f"[WARN] curl: failed to fetch {url}: {e}")
122122
return ""

0 commit comments

Comments
 (0)