refactor(computer_use): tool.py — nullcontext in _stop_backend

This commit is contained in:
Teknium
2026-09-02 15:54:13 -07:00
parent 1d676837e0
commit d4b59e044c

View File

@@ -185,10 +185,7 @@ def _pop_session_locked(sid: str) -> Tuple[Optional[ComputerUseBackend], Optiona
def _stop_backend(backend: ComputerUseBackend, call_lock: Optional[threading.RLock]) -> None:
"""Stop under the session call lock (if any) so an in-flight action finishes first.
Never called under ``_backend_lock``: unrelated sessions stay free meanwhile. Raises."""
if call_lock is not None:
with call_lock:
backend.stop()
else:
with call_lock if call_lock is not None else contextlib.nullcontext():
backend.stop()
def _get_backend(session_id: str = "") -> ComputerUseBackend: