Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/main.py: 73%
9 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 14:22 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 14:22 +0000
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
18from __future__ import annotations
20import os
21import sys
23# Mark this as a server context before any airflow imports
24# This ensures plugins loaded at import time get the correct secrets backend chain
25os.environ["_AIRFLOW_PROCESS_CONTEXT"] = "server"
27# Warn if PYTHONASYNCIODEBUG or PYTHONDEVMODE is set on Python 3.12+ (see Airflow issue #61214)
28if sys.version_info >= (3, 12) and ( 28 ↛ 31line 28 didn't jump to line 31 because the condition on line 28 was never true
29 os.environ.get("PYTHONASYNCIODEBUG") == "1" or os.environ.get("PYTHONDEVMODE") == "1"
30):
31 import warnings
33 warnings.warn(
34 "PYTHONASYNCIODEBUG or PYTHONDEVMODE detected on Python 3.12+: "
35 "The API server may crash due to uvloop incompatibility with asyncio debug mode. "
36 "See https://github.com/apache/airflow/issues/61214 for details.",
37 RuntimeWarning,
38 stacklevel=2,
39 )
41from airflow.api_fastapi.app import cached_app
43# There is no way to pass the apps to this file from Airflow CLI
44# because fastapi dev command does not accept any additional arguments
45# so environment variable is being used to pass it
46app = cached_app(apps=os.environ.get("AIRFLOW_API_APPS", "all"))