Skip to content

API reference

lifespan(app) async

Opens the checkpointer once at process startup, so an interrupted case review survives a server restart — not just an in-memory pause within one process (graph/builder.py's checkpointer parameter).

Source code in src/cohort/api/main.py
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
    """Opens the checkpointer once at process startup, so an interrupted
    case review survives a server restart — not just an in-memory pause
    within one process (`graph/builder.py`'s `checkpointer` parameter)."""
    async with aiosqlite.connect(settings.checkpoint_db_path) as conn:
        app.state.checkpointer = AsyncSqliteSaver(conn, serde=build_checkpoint_serializer())
        yield