MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / _quiet_cleanup

Function _quiet_cleanup

mini_agent/cli.py:470–483  ·  view source on GitHub ↗

Clean up MCP connections, suppressing noisy asyncgen teardown tracebacks.

()

Source from the content-addressed store, hash-verified

468
469
470async def _quiet_cleanup():
471 """Clean up MCP connections, suppressing noisy asyncgen teardown tracebacks."""
472 # Silence the asyncgen finalization noise that anyio/mcp emits when
473 # stdio_client's task group is torn down across tasks. The handler is
474 # intentionally NOT restored: asyncgen finalization happens during
475 # asyncio.run() shutdown (after run_agent returns), so restoring the
476 # handler here would still let the noise through. Since this runs
477 # right before process exit, swallowing late exceptions is safe.
478 loop = asyncio.get_event_loop()
479 loop.set_exception_handler(lambda _loop, _ctx: None)
480 try:
481 await cleanup_mcp_connections()
482 except Exception:
483 pass
484
485
486async def run_agent(workspace_dir: Path, task: str = None):

Callers 1

run_agentFunction · 0.85

Calls 1

cleanup_mcp_connectionsFunction · 0.90

Tested by

no test coverage detected