fix: preserve real cancellation in MCP paths
This commit is contained in:
@@ -111,6 +111,34 @@ class TestHandleStop:
|
||||
|
||||
|
||||
class TestDispatch:
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_logs_and_continues_after_leaked_cancelled_error(self, monkeypatch):
|
||||
loop, bus = _make_loop()
|
||||
loop._connect_mcp = AsyncMock()
|
||||
loop.close_mcp = AsyncMock()
|
||||
loop.auto_compact.check_expired = MagicMock()
|
||||
warnings: list[str] = []
|
||||
calls = 0
|
||||
|
||||
async def consume_once_then_stop():
|
||||
nonlocal calls
|
||||
calls += 1
|
||||
if calls == 1:
|
||||
raise asyncio.CancelledError()
|
||||
loop.stop()
|
||||
raise asyncio.TimeoutError()
|
||||
|
||||
monkeypatch.setattr(bus, "consume_inbound", consume_once_then_stop)
|
||||
monkeypatch.setattr(
|
||||
"nanobot.agent.loop.logger.warning",
|
||||
lambda message, *args, **kwargs: warnings.append(message),
|
||||
)
|
||||
|
||||
await loop.run()
|
||||
|
||||
assert calls == 2
|
||||
assert any("Ignoring leaked CancelledError" in warning for warning in warnings)
|
||||
|
||||
def test_exec_tool_not_registered_when_disabled(self):
|
||||
from nanobot.agent.tools.shell import ExecToolConfig
|
||||
from nanobot.config.schema import ToolsConfig
|
||||
|
||||
Reference in New Issue
Block a user