From ec189ccd2b258511cc9367c33520e03c047cd350 Mon Sep 17 00:00:00 2001 From: Kevin Hsiao Date: Tue, 24 Nov 2026 16:05:22 +0800 Subject: [PATCH] fix(benchmark): pass OpenSandbox instance to _invalidate_sandbox (#8561) Follow-up to #8507 (`6cefec0c9`), which changed `OpenSandboxProvider._invalidate_sandbox` to accept an `OpenSandboxSandbox` instance instead of `sandbox_id: str`. Look up the active or warm sandbox instance under `self._lock` inside `BenchmarkOpenSandboxProvider.destroy()` before calling `_invalidate_sandbox()`. --- backend/scripts/benchmark/sandbox/bench_provider.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/scripts/benchmark/sandbox/bench_provider.py b/backend/scripts/benchmark/sandbox/bench_provider.py index 23a507408e..253347b989 100644 --- a/backend/scripts/benchmark/sandbox/bench_provider.py +++ b/backend/scripts/benchmark/sandbox/bench_provider.py @@ -320,7 +320,13 @@ def _make_opensandbox_provider(config: dict[str, Any]) -> tuple[Any, dict[str, A # The runner calls this after release. Reuse the provider's owner of # identity removal instead of separately editing its three maps. with self._acquire_serializer.hold(sandbox_id): - self._invalidate_sandbox(sandbox_id, reason="benchmark_no_warmpool") + with self._lock: + sandbox = self._sandboxes.get(sandbox_id) + if sandbox is None: + warm_entry = self._warm_pool.get(sandbox_id) + sandbox = warm_entry[0] if warm_entry is not None else None + if sandbox is not None: + self._invalidate_sandbox(sandbox, reason="benchmark_no_warmpool") self._check_cleanup() def shutdown(self) -> None: