Skip to content

The agent that grows with you

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

Tekniumd4b59e044ced
diff --git a/tools/computer_use/tool.py b/tools/computer_use/tool.py
index 6a09e56ba53..5cafe5ae20f 100644
--- a/tools/computer_use/tool.py
+++ b/tools/computer_use/tool.py
@@ -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: