Repository navigation
Stop a language SDK task's children when the task is stopped - #75545
Closed
namanjain24-sudo wants to merge 1 commit into
Closed
namanjain24-sudo wants to merge 1 commit into
namanjain24-sudo wants to merge 1 commit into
Conversation
The coordinators start a language runtime with subprocess.Popen and leave it in the supervisor's own process group, so stopping the task signals the runtime alone. Anything the task started -- a CLI spawned from a TypeScript handler, say -- is re-parented to init and keeps running alongside the next try, and holds the runtime's event loop open until the SIGKILL escalation fires. Python tasks stopped leaking this way in apache#65505 by running in their own process group so the supervisor can signal the whole group. Giving the runtime the same treatment is all that _signal_subprocess needs to reach it with os.killpg.
Member
|
#75707 is more progressed. |
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.
The coordinators start a language runtime with
subprocess.Popenand leave it in the supervisor's ownprocess group, so stopping the task signals the runtime alone. Anything the task started — a CLI spawned
from a TypeScript handler, for instance — is re-parented to init and keeps running alongside the next try,
and holds the runtime's event loop open until the SIGKILL escalation fires after
killed_task_cleanup_time.Python tasks stopped leaking this way in #65505: the task process runs in its own process group so the
supervisor can signal the whole group.
WatchedSubprocess._signal_subprocessalready does that withos.killpgwhenevernew_process_groupwas recorded at start time, so the runtime only needs the sametreatment —
process_group=0on thePopen, and the flag set on the subprocess object.This is direction 1 of the two the issue lists. It fixes every path that stops the task, since they all go
through
_signal_subprocess: clearing a running task,execution_timeout, repeated heartbeat failures andtask-success overtime.
process_groupis POSIX-only, which matches the rest of this machinery — the Python path already callsos.posix_spawn(..., setpgroup=0)andos.fork()+os.setpgidunconditionally.closes: #75533
Testing
Checked the real behaviour rather than only the call, with a runtime that spawns a child the way the
issue's handler does:
_signal_subprocesstakes thekillpgpath. It fails without the change (KeyError: 'process_group').task-sdk/tests/task_sdk/coordinators/— 475 passed.task-sdk/tests/task_sdk/execution_time/test_supervisor.py— 374 passed, 1 skipped.breeze run mypy task-sdk/src/airflow/sdk/coordinators/_subprocess.py— clean.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines