diff --git a/airflow-core/src/airflow/utils/serve_logs/log_server.py b/airflow-core/src/airflow/utils/serve_logs/log_server.py index 16acd64c538fa..49f4df1ce5a5f 100644 --- a/airflow-core/src/airflow/utils/serve_logs/log_server.py +++ b/airflow-core/src/airflow/utils/serve_logs/log_server.py @@ -20,6 +20,7 @@ import logging import os +from functools import cache from typing import cast from fastapi import FastAPI, HTTPException, Request, status @@ -157,12 +158,7 @@ def create_app(): return fastapi_app -app = None - - -def get_app(): - """Get or create the FastAPI app instance.""" - global app - if app is None: - app = create_app() - return app +@cache +def get_app() -> FastAPI: + """Create a cached FastAPI app instance.""" + return create_app()