#1223 fixes, timeout for downloads

This commit is contained in:
Flowseal committed 2026-10-10 22:08:57 +03:00
1 parent a6177fec87
commit bf07b42f88
4 files changed
+55 -30

No files matched your search

+2
View File
@@ -34,6 +34,7 @@ def _run_quiet(cmd: List[str]) -> bool:
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=15,
env=relaunch_env(),
).returncode == 0
except (OSError, subprocess.SubprocessError):
return False
@@ -107,6 +108,7 @@ def _run_install(cmd: List[str], log: Optional[logging.Logger] = None) -> Option
proc = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
timeout=_INSTALL_TIMEOUT_SEC,
env=relaunch_env(),
)
if proc.returncode == 0:
return None
+3 -1
View File
@@ -271,12 +271,14 @@ def _expected_length(resp: Any) -> Optional[int]:
def download_asset(
url: str, dest_dir: Path, suffix: str = ".tmp", digest: str = "",
timeout: float = 30.0,
) -> Path:
"""Download a release asset into a temporary file inside dest_dir.
The size is checked against Content-Length and, when the GitHub API
provides a "sha256:..." digest, the checksum too. A truncated or
corrupted file is removed instead of being returned.
timeout limits blocking network operations, including response reads.
Raises:
OSError: network error, truncated download or checksum mismatch.
@@ -287,7 +289,7 @@ def download_asset(
try:
sha = hashlib.sha256()
written = 0
with build_github_opener().open(url) as resp:
with build_github_opener().open(url, timeout=timeout) as resp:
expected = _expected_length(resp)
with open(str(path), "wb") as out:
while True: