File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ def _spawn_work_order_generator(work_order_id: int) -> None:
494494 instead of a throwaway stub.
495495 """
496496 try :
497- from agents .work_order_generator import (# type: ignore[import-not-found]
497+ from agents .work_order_generator import ( # type: ignore[import-not-found]
498498 run_work_order_generator ,
499499 )
500500 except ImportError :
Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import asyncio
56import logging
67from contextlib import asynccontextmanager
78
9+ from agents .sentinel import sentinel_loop
810from aria_mcp .server import http_app as mcp_http_app
911from core .config import get_settings
1012from core .database import db
@@ -38,9 +40,19 @@ async def lifespan(app: FastAPI):
3840 log .info ("ARIA backend ready" )
3941 async with mcp_http_app .lifespan (mcp_http_app ):
4042 log .info ("MCP server ready at /mcp" )
43+ # Sentinel must start INSIDE the MCP lifespan wrapper — its first
44+ # `mcp_client.call_tool()` hits 404 otherwise (MCP HTTP app not
45+ # yet mounted). See #26 audit comment.
46+ sentinel_task = asyncio .create_task (sentinel_loop (), name = "sentinel" )
4147 try :
4248 yield
4349 finally :
50+ sentinel_task .cancel ()
51+ try :
52+ await sentinel_task
53+ except asyncio .CancelledError :
54+ pass
55+ log .info ("Sentinel cancelled" )
4456 await db .disconnect ()
4557
4658
You can’t perform that action at this time.
0 commit comments