Make Task SDK supervisor subprocess a session leaderFix supervisor session leader - #70950
Open
KushagraB424 wants to merge 1 commit into
Open
Make Task SDK supervisor subprocess a session leaderFix supervisor session leader#70950KushagraB424 wants to merge 1 commit into
KushagraB424 wants to merge 1 commit into
Conversation
KushagraB424
force-pushed
the
fix-supervisor-session-leader
branch
from
August 2, 2026 21:29
0d80ca8 to
9704b18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background & Problem
In
task-sdk/src/airflow/sdk/execution_time/supervisor.py, the_subprocess_mainfunction is the entry point for the child process that runs the user's task code. An existingTODOcomment indicated that this child process should be made a session leader.If the process is not a session leader, it remains in the same process group as the parent supervisor. This means that if a signal (like
SIGINTorSIGTERM) is sent to the parent process group, both the parent and the child would receive it independently, potentially leading to double-firing of signal handlers and race conditions during shutdown or interruption.The Solution
This PR resolves the
TODOby making the child process a session leader immediately upon startup.We introduced a call to
os.setsid()inside atry...except OSErrorblock, guarded byhasattr(os, "setsid")to ensure cross-platform compatibility (especially for Windows environments wheresetsidmight not be available). This isolates the child process into its own session and process group, ensuring that signals are handled explicitly through the supervisor's lifecycle management rather than broadcasted by the OS terminal.Impacted Files
[MODIFY] task-sdk/src/airflow/sdk/execution_time/supervisor.py
Testing & Verification
os.setsid()is unavailable or fails.closes: #70949
Was generative AI tooling used to co-author this PR?
Generated-by: Antigravity IDE following the guidelines