Skip to content

Boxtalk - FastAPI App

life_cycle(app) async

Lifecycle event handler for the FastAPI application.

Parameters:

Name Type Description Default
app FastAPI

The FastAPI application instance.

required
Source code in mycxo/boxtalk/app.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@asynccontextmanager
async def life_cycle(app: FastAPI) -> AsyncGenerator[None, None]:
    """
    Lifecycle event handler for the FastAPI application.

    Args:
        app (FastAPI): The FastAPI application instance.
    """
    logfire.instrument_requests()
    logfire.instrument_aiohttp_client()
    logfire.instrument_httpx()
    logger.info("Started")
    yield
    executor.shutdown_executor()
    logger.info("Stopped")