Skip to content

The agent that grows with you

fix(pm): keep warm standalone lookups independent of writers

ethernet4e1c317f06a1
diff --git a/pm/ensure.py b/pm/ensure.py
index 67666a4854b..59441a13706 100644
--- a/pm/ensure.py
+++ b/pm/ensure.py
@@ -442,11 +442,6 @@ def ensure(
sync_venv(explicit=explicit)
return Runner(name, compose_env([], base=base_env))
- if explicit and _operation is None:
- with _install_operation() as operation:
- return ensure(name, base_env=base_env, explicit=True, progress=progress,
- pause_event=pause_event, download_progress=download_progress,
- _operation=operation)
lockfile = _lockfile()
target = current_target()
chain = walk([name])
diff --git a/tests/pm/test_pm_core.py b/tests/pm/test_pm_core.py
index a24d2e8101e..d64b7d34855 100644
--- a/tests/pm/test_pm_core.py
+++ b/tests/pm/test_pm_core.py
@@ -314,6 +314,21 @@ def test_warm_install_verifies_shared_dependencies_once_under_lock(pm_env, monke
assert binary.read_text(encoding="utf-8") == "deptool"
+def test_standalone_warm_ensure_does_not_wait_for_unrelated_writer(pm_env):
+ from concurrent.futures import ThreadPoolExecutor
+ from pm.ensure import ensure
+
+ _, runtime, _, _ = pm_env
+ ensure("faketool", explicit=True)
+ with ThreadPoolExecutor(max_workers=1) as pool:
+ with Store(runtime).install_lock():
+ # A downloader can hold this lock for minutes. A healthy unrelated
+ # tool must remain usable without waiting for that writer to finish.
+ future = pool.submit(ensure, "faketool", explicit=True, base_env={})
+ runner = future.result(timeout=3)
+ assert "faketool-1.0" in runner.env["PATH"]
+
+
def test_install_forgets_verification_when_state_operation_releases_lock(pm_env, monkeypatch):
import importlib
import os