Apply simplify pass: flatten the batch worker, drop a dead guard, skip the unread backoff probe

This commit is contained in:
J. Nick Koston
2026-08-24 12:20:14 -05:00
parent d348284d9e
commit 29c290166b
2 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -791,7 +791,7 @@ def _prefetch_idf_tool_archives(
# failure_reason: a message-less exception must not log blank
_LOGGER.warning("Could not prefetch %s: %s", name, failure_reason(e))
_LOGGER.debug("Prefetch failure detail", exc_info=e)
if failures and len(failures) == len(entries):
if len(failures) == len(entries):
# A systematic fault, not one flaky mirror: the resume
# workaround (#17703) is off for this whole install
_LOGGER.error(
+15 -15
View File
@@ -776,16 +776,14 @@ def run_batch_downloads(
try:
fetch(checked)
except (_BatchDownloadCancelled, Exception) as err: # noqa: BLE001 # pylint: disable=broad-exception-caught
# A cancelled job reports like a failure: an abandoned download
# must never read as completed if a caller sees the list after
# Ctrl-C
failure = (name, err)
else:
return None
# A bar-frame write failure must not displace the download error
with suppress(Exception):
tracker(0)
return failure
# The cancelled arm exists for the tracker rollback below; the
# batch re-raises the interrupt, so the list is never returned
# after Ctrl-C. A bar-frame write failure must not displace the
# download error.
with suppress(Exception):
tracker(0)
return (name, err)
return None
ex = ThreadPoolExecutor(max_workers=max_workers)
try:
@@ -1316,11 +1314,13 @@ def download_from_mirrors(
)
# Tick with the bytes already on disk so a combined bar holds
# steady during the backoff instead of rewinding to zero
if f is not None:
done = f.tell()
else:
part = _part_path(path_target)
done = part.stat().st_size if part.is_file() else 0
done = 0
if progress is not None:
if f is not None:
done = f.tell()
else:
part = _part_path(path_target)
done = part.stat().st_size if part.is_file() else 0
_cancellable_sleep(delay, progress, done)
# 4. Report every attempted URL if all mirrors failed. failures spans