(app: FastAPI)
| 57 | |
| 58 | @asynccontextmanager |
| 59 | async 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 |
| 73 | app = FastAPI(lifespan=lifespan) |
nothing calls this directly
no test coverage detected