INNER CODE UNIT · Python

lifespan

grillazz/fastapi-sqlalchemy-asyncpg · app/main.py:30

async def lifespan(app: FastAPI):
    app.logger = get_logger()
    app.redis = await get_redis()
    global_settings.postgres_url.unicode_string()
    # Chat service: initialize the pluggable model-client adapter. The session
    # manager is now a singleton and will be auto-instantiated on first access.
    # See app/services/chat_agent.py to swap the local stub for a real model
    # client (OpenAI, Ollama, etc.).
    app.chat_agent = build_chat_agent(global_settings.chat)
    try:
        # app.postgres_pool = await asyncpg.create_pool(
        #     dsn=postgres_dsn,
        #     min_size=5,
        #     max_size=20,
        # )
        # await app.logger.ainfo(
        #     "Postgres pool created", idle_size=app.postgres_pool.get_idle_size()
        # )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…