From 9704b18fce98742e312d552dc0586095100c6fe1 Mon Sep 17 00:00:00 2001 From: Kushagra Gupta Date: Mon, 3 Aug 2026 02:50:23 +0530 Subject: [PATCH] Make Task SDK supervisor subprocess a session leader --- task-sdk/src/airflow/sdk/execution_time/supervisor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/task-sdk/src/airflow/sdk/execution_time/supervisor.py b/task-sdk/src/airflow/sdk/execution_time/supervisor.py index 87311f02da7a1..f2d435d72e1eb 100644 --- a/task-sdk/src/airflow/sdk/execution_time/supervisor.py +++ b/task-sdk/src/airflow/sdk/execution_time/supervisor.py @@ -418,7 +418,12 @@ def _fork_main( - Catch un-handled exceptions and attempt to show _something_ in case of error - Finally, run the actual task runner code (``target`` argument, defaults to ``.task_runner:main`) """ - # TODO: Make this process a session leader + # Make this process a session leader + if hasattr(os, "setsid"): + try: + os.setsid() + except OSError: + pass # Store original stderr for last-chance exception handling last_chance_stderr = _get_last_chance_stderr()