This is an automated email from the ASF dual-hosted git repository. dstandish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 975337a50a Skip get_current_task_instance_session if use_internal_api (#39595) 975337a50a is described below commit 975337a50a4f64a1adfb6cebf45133006d4f3bcb Author: Daniel Standish <15932138+dstand...@users.noreply.github.com> AuthorDate: Mon May 13 20:47:23 2024 -0700 Skip get_current_task_instance_session if use_internal_api (#39595) We don't need a session when configured to use the internal API. --- airflow/utils/task_instance_session.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airflow/utils/task_instance_session.py b/airflow/utils/task_instance_session.py index bb9741bf52..e434c4d3ec 100644 --- a/airflow/utils/task_instance_session.py +++ b/airflow/utils/task_instance_session.py @@ -23,6 +23,7 @@ import traceback from typing import TYPE_CHECKING from airflow import settings +from airflow.api_internal.internal_api_call import InternalApiConfig if TYPE_CHECKING: from sqlalchemy.orm import Session @@ -35,6 +36,8 @@ log = logging.getLogger(__name__) def get_current_task_instance_session() -> Session: global __current_task_instance_session if not __current_task_instance_session: + if InternalApiConfig.get_use_internal_api(): + return __current_task_instance_session log.warning("No task session set for this task. Continuing but this likely causes a resource leak.") log.warning("Please report this and stacktrace below to https://github.com/apache/airflow/issues") for filename, line_number, name, line in traceback.extract_stack():