INNER CODE UNIT · Python

lifespan

scub-france/docling-Studio · document-parser/main.py:48

async def lifespan(app: FastAPI) -> AsyncIterator[None]:
    builder = AppStateBuilder(publish=lambda state: setattr(app.state, "container", state))
    state = await builder.build()

    # Mounted conditionally: without an ingestion service every route would
    # 503, so the surface stays out of OpenAPI entirely.
    if state.ingestion_service is not None:
        app.include_router(ingestion_router)
        logger.info("Ingestion router mounted")

    try:
        yield
    finally:
        # Drain both backend pools (#279). `close_driver` drains the Neo4j
        # pool (every (uri, user) entry, not just the env-based one); the
        # OpenSearch pool is drained explicitly.
        from infra.neo4j import close_driver
        from infra.opensearch_pool import get_pool as get_opensearch_pool

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…