fix(exec): clean up sessions on shutdown

This commit is contained in:
KDB
2026-07-21 13:48:51 +08:00
committed by Xubin Ren
parent 7cf3c71e3a
commit 8981995474
10 changed files with 390 additions and 12 deletions
+16
View File
@@ -114,6 +114,22 @@ class TestSpawnUnix:
kwargs = mock_exec.call_args[1]
assert kwargs["stdin"] == asyncio.subprocess.DEVNULL
@pytest.mark.asyncio
async def test_process_tree_starts_new_session(self):
with (
patch("nanobot.agent.tools.shell._IS_WINDOWS", False),
patch("asyncio.create_subprocess_exec", new_callable=AsyncMock) as mock_exec,
):
mock_exec.return_value = AsyncMock()
await ExecTool._spawn(
"echo hi",
"/tmp",
{"HOME": "/tmp"},
process_tree=True,
)
assert mock_exec.call_args.kwargs["start_new_session"] is True
class TestSpawnWindows: