The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(mcp): flatten _LockCookie.release nested try ladders (same best-effort semantics)
Tekniume59090acee74
diff --git a/tools/mcp_tool_loop.py b/tools/mcp_tool_loop.pyindex 87f90579c20..7c3a0f57d0f 100644--- a/tools/mcp_tool_loop.py+++ b/tools/mcp_tool_loop.py@@ -30,28 +30,24 @@ class _LockCookie:self._fh = fhdef release(self) -> None:- if self._fh is not None:- try:- fd = self._fh.fileno()- if os.name == "posix":- import fcntl- try:- fcntl.flock(fd, fcntl.LOCK_UN)- except Exception:- pass- else:- import portalocker- try:- portalocker.unlock(self._fh)- except Exception:- pass- except Exception:- pass- try:- self._fh.close()- except Exception:- pass- self._fh = None+ if self._fh is None:+ return+ # Best effort on every step: an unlock/close failure must never+ # propagate out of discovery.+ try:+ if os.name == "posix":+ import fcntl+ fcntl.flock(self._fh.fileno(), fcntl.LOCK_UN)+ else:+ import portalocker+ portalocker.unlock(self._fh)+ except Exception:+ pass+ try:+ self._fh.close()+ except Exception:+ pass+ self._fh = Nonedef _acquire_lock_on_fh(fh: Any) -> bool: