Skip to content

Run task callbacks in fresh interpreters - #73380

Open
keith991001 wants to merge 2 commits into
apache:mainfrom
keith991001:codex/callback-subprocess-exec
Open

keith991001 wants to merge 2 commits into
apache:mainfrom
keith991001:codex/callback-subprocess-exec

Conversation

@keith991001

@keith991001 keith991001 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Callbacks previously used a closure as their subprocess target, which prevented them from using the fresh-interpreter path and left them exposed to locks inherited from supervisor threads.

This change adds an importable callback child entry point, sends its startup data over the existing supervisor socket, and applies execute_tasks_new_python_interpreter to callback subprocesses. It includes focused tests, a real fork+exec regression test, configuration documentation, and a significant newsfragment.

Rebased on current main on 2026-11-11. The callback startup message preserves upstream callback-kwargs encoding and XCom context support. Bare-fork mode retains task-runner preloading; exec mode skips that preload.

Current validation: Ruff formatting/lint and git diff --check pass. Linux callback execution, task-sdk typing, and full pre-commit checks are delegated to GitHub CI because this checkout is on Windows without Breeze/Docker. The current Tests (AMD) and CodeQL runs require maintainer approval. A Linux before/after performance benchmark remains outstanding.

closes: #73143


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-5), with the current rebase assisted by Codex (GPT-6)

Generated-by: Codex (GPT-6) following the guidelines


Drafted-by: Codex (GPT-6); reviewed by @keith991001 before posting

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Nov 10, 2026
@keith991001
keith991001 force-pushed the codex/callback-subprocess-exec branch from 829870b to c5b7407 Compare November 11, 2026 08:43
@keith991001

Copy link
Copy Markdown
Contributor Author

Rebased on current main and pushed c5b7407. The startup protocol preserves the upstream callback kwargs encoding and XCom context support, and task-runner preloading remains limited to bare-fork mode. Ruff and diff checks pass. This PR is still active; the current Tests (AMD) run and CodeQL require maintainer approval. Linux runtime checks and the before/after performance benchmark are still pending.


Drafted-by: Codex (GPT-6); reviewed by @keith991001 before posting

@github-actions github-actions Bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Nov 12, 2026
Callback processes could inherit locks held by supervisor threads because their closure-based target required a bare fork. On current main, fresh interpreters start through the shared posix_spawn path, so the conflict resolution keeps that mechanism and gives callbacks an importable child entry point.

Test Plan:

```
uv run --project task-sdk pytest task-sdk/tests/task_sdk/execution_time/test_callback_supervisor.py -xvs
uv run --project task-sdk pytest task-sdk/tests/task_sdk/execution_time/test_callback_supervisor.py::test_callback_fresh_interpreter_end_to_end -xvs
uv run --no-sync ruff check --fix task-sdk/src/airflow/sdk/execution_time/supervisor.py task-sdk/src/airflow/sdk/execution_time/callback_supervisor.py task-sdk/tests/task_sdk/execution_time/exec_probe_target.py task-sdk/tests/task_sdk/execution_time/test_callback_supervisor.py
```

Authored with assistance from Codex.
@keith991001
keith991001 force-pushed the codex/callback-subprocess-exec branch from c5b7407 to a63aee5 Compare November 27, 2026 05:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task SDK: importable entry point for callback subprocesses so they can use fork+exec

2 participants