INNER CODE UNIT · Python

lifespan

CronusL-1141/AI-company · src/aiteam/api/app.py:93

async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
    """Observe lifecycle boundaries without changing dependency ownership."""
    startup_process = capture_process_snapshot()
    with observe_signals(startup_process):
        phase = "startup"
        # Which Dashboard build this process serves (pick_dashboard_dist): the
        # startup record is where a stale interface can be traced back to.
        record_lifecycle_event("api.startup.begin", startup_process=startup_process,
                               dashboard_dist=getattr(app.state, "dashboard_dist", ""))
        try:
            async with _application_lifespan(app):
                record_lifecycle_event("api.startup.complete", startup_process=startup_process)
                phase = "running"
                yield
                phase = "shutdown"
                record_lifecycle_event("api.shutdown.begin", startup_process=startup_process)
            record_lifecycle_event("api.shutdown.complete", startup_process=startup_process)
        except BaseException as exc:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…