MCPcopy Create free account
hub / github.com/Roy3838/Observer / lifespan

Function lifespan

api/api.py:59–70  ·  view source on GitHub ↗
(app: FastAPI)

Source from the content-addressed store, hash-verified

57
58@asynccontextmanager
59async def lifespan(app: FastAPI):
60 # Runs once in each uvicorn worker, so each gets its own pool.
61 asyncio.get_running_loop().set_default_executor(
62 ThreadPoolExecutor(max_workers=IO_THREADS, thread_name_prefix="io")
63 )
64 await api_handlers.startup_handlers()
65 # One per worker; the sweep claims atomically, so each stopped session is announced once.
66 sweeper = asyncio.create_task(deadman_sweeper())
67 yield
68 sweeper.cancel()
69 await api_handlers.shutdown_handlers()
70 await close_redis()
71
72# Setup FastAPI app
73app = FastAPI(lifespan=lifespan)

Callers

nothing calls this directly

Calls 2

deadman_sweeperFunction · 0.90
close_redisFunction · 0.90

Tested by

no test coverage detected