Skip to content

Commit

Permalink
Use TracebackSession when internal API configured and getting current…
Browse files Browse the repository at this point in the history
… session (#39600)

We shouldn't use this session; this class will tell you where it came from.
  • Loading branch information
dstandish committed May 14, 2024
1 parent 975337a commit 05b6b74
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions airflow/utils/task_instance_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from airflow import settings
from airflow.api_internal.internal_api_call import InternalApiConfig
from airflow.settings import TracebackSession

if TYPE_CHECKING:
from sqlalchemy.orm import Session
Expand All @@ -37,6 +38,7 @@ def get_current_task_instance_session() -> Session:
global __current_task_instance_session
if not __current_task_instance_session:
if InternalApiConfig.get_use_internal_api():
__current_task_instance_session = TracebackSession()
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")
Expand Down

0 comments on commit 05b6b74

Please sign in to comment.