test(agent): close session input fixtures and share shutdown diagnostics
This commit is contained in:
1 parent
2756c6bb78
commit
90fcb7f903
3 files changed
+29
-27
No files matched your search
@@ -1,6 +1,7 @@
|
||||
"""Session-worker completion helpers for integration tests."""
|
||||
|
||||
import asyncio
|
||||
import faulthandler
|
||||
import time
|
||||
|
||||
from nanobot.agent.loop import AgentLoop
|
||||
@@ -38,6 +39,19 @@ async def run_session(loop: AgentLoop, msg: InboundMessage) -> None:
|
||||
await asyncio.gather(*loop._active_tasks[loop._effective_session_key(msg)])
|
||||
|
||||
|
||||
async def stop_loop(loop: AgentLoop, worker: asyncio.Task[None], *, timeout: float) -> None:
|
||||
"""Stop an integration loop, retaining native shutdown stacks on timeout."""
|
||||
loop.stop()
|
||||
try:
|
||||
await asyncio.wait_for(worker, timeout=timeout)
|
||||
except TimeoutError:
|
||||
close_task = loop.sessions.state._close_task
|
||||
if close_task is not None:
|
||||
close_task.print_stack()
|
||||
faulthandler.dump_traceback()
|
||||
raise
|
||||
|
||||
|
||||
def mock_session_manager(*_args, **_kwargs):
|
||||
"""Model the asynchronous state boundary in scheduler-only unit tests."""
|
||||
from unittest.mock import AsyncMock, MagicMock
|
||||
|
||||
Reference in new issue
Block a user