Run the sequential remainder after the batch

This commit is contained in:
J. Nick Koston
2026-08-27 19:21:15 -05:00
parent 2b64db9942
commit b2e626d484
2 changed files with 8 additions and 5 deletions
+6 -5
View File
@@ -389,11 +389,8 @@ def install_packages(specs: Collection[PackageSpec], downloads_dir: Path) -> Non
seen.add(archive.name)
pending.append((spec, size))
if len(pending) < 2:
rest = list(specs)
pending = []
for name, version, dest, mirrors, expect in rest:
install_package(name, version, dest, mirrors, downloads_dir, expect=expect)
if not pending:
for name, version, dest, mirrors, expect in specs:
install_package(name, version, dest, mirrors, downloads_dir, expect=expect)
return
workers = min(get_usable_cpu_count(), len(pending), BATCH_EXTRACT_WORKERS)
_LOGGER.info(
@@ -425,3 +422,7 @@ def install_packages(specs: Collection[PackageSpec], downloads_dir: Path) -> Non
# not name which package failed
warn_batch_failures(failures, "Could not install %s: %s")
raise failures[0][1]
# Sequential remainder after the batch, so a duplicate spec cannot
# unlink the archive its batched twin was sized from
for name, version, dest, mirrors, expect in rest:
install_package(name, version, dest, mirrors, downloads_dir, expect=expect)
@@ -906,6 +906,8 @@ def test_install_packages_dedupes_duplicate_specs(tmp_path: Path) -> None:
batched = [c for c in mock_install.call_args_list if "extract_progress" in c[1]]
assert [(c[0][0], c[0][2]) for c in sequential] == [("a", tmp_path / "a2")]
assert sorted(c[0][0] for c in batched) == ["a", "b"]
# The duplicate runs after the batch, which unlinks their shared archive
assert mock_install.call_args_list[-1] == sequential[0]
def test_install_packages_caps_workers(tmp_path: Path) -> None: