From 8abc8d329132ea5a8025b72a2175551bb387a24f Mon Sep 17 00:00:00 2001 From: Shengqi Chen Date: Sat, 13 Sep 2025 15:34:11 +0800 Subject: [PATCH] github-release: add timeout when reading from HTTP connection [ci skip] Signed-off-by: Shengqi Chen --- github-release.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/github-release.py b/github-release.py index d1b95fb..9ddc7a5 100755 --- a/github-release.py +++ b/github-release.py @@ -4,7 +4,6 @@ import json import logging import os import tempfile -import traceback from datetime import datetime from pathlib import Path @@ -45,6 +44,7 @@ def github_get(*args, **kwargs) -> requests.Response: headers["Authorization"] = "token {}".format(os.environ["GITHUB_TOKEN"]) headers["User-Agent"] = UA kwargs["headers"] = headers + kwargs["timeout"] = TIMEOUT_OPTION return requests.get(*args, **kwargs) @@ -63,7 +63,8 @@ def do_download( delete=False, ) as f: tmp_dst_file = Path(f.name) - for chunk in r.iter_content(chunk_size=1024**2): + # download in 1MB chunks + for chunk in r.iter_content(chunk_size=1 << 20): if chunk: # filter out keep-alive new chunks f.write(chunk) # f.flush()