Support parent/child tasks - #60
Merged
Merged
Conversation
0.29 generates `datetime.fromisoformat` calls in place of `dateutil.isoparse`. That can't parse the API's `Z`-suffixed timestamps before Python 3.11, and we support 3.10. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds `parent` to the task request/response models and a `parent` query filter on task list. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Also exports `list_tasks`, which the new parent filter makes the natural way to fetch a task's children. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Celery and Procrastinate tasks enqueued while another tracked task is running are attached to it as children, as are tasks created inside `@track`. Nesting is one level deep, so entering a task that already has a parent keeps offering that parent: a task enqueued by a child joins it under the root rather than hanging off it, which the API would reject. Replaces Procrastinate's private current-task contextvar with the shared one so `current_task()` and parenting can't drift apart. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Celery dispatches the next chain link and any `link` callbacks from inside `trace_task` after the body returns but before `task_postrun`, so the task they follow still looks current and they were being recorded as its children. They're successors, not subtasks. Nothing on the wire distinguishes them from a publish the body made itself, so this matches against the running task's own `request.chain`/`request.callbacks` rather than inspecting the stack. Retries still nest — a retry republishes the same task, which isn't among its own successors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
snopoke
marked this pull request as ready for review
August 6, 2026 13:54
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 server API now supports parent/child tasks, one level deep, set via a
parentfield when creating a task.create_task/update_task/list_taskstakeparentexplicitly. The Celery, Procrastinate and@trackintegrations set it automatically for tasks enqueued while another tracked task is running — a barecreate_tasknever picks up an ambient parent, only the integrations nest.Worth review attention:
linkcallbacks don't. Celery dispatches all of these from insidetrace_taskafter the body returns but beforetask_postrun, so they all look like they came from the running task. Nothing on the wire separates them, so chain/callback publishes are matched against the running task's ownrequest.chain/request.callbacksrather than by inspecting the stack. Known edge case: if a chain's next link is also called directly from the body, that direct call won't nest.datetime.fromisoformatin place ofdateutil.isoparse, which can't parse the API'sZ-suffixed timestamps on Python 3.10. Without the pin, every task create/get/update breaks on 3.10. Side effect: devtyperresolves to 0.25.1, since the generator shares that dependency.Verified against the deployed service: integration tests cover create/list/update, the one-level limit, Celery parent nesting, grandchild flattening and chain links. The flattening and chain-link tests were checked by reverting the fix and confirming they fail, rather than only that they pass. Unit suite passes on both 3.10 and 3.14.
Deliberately out of scope: a CLI
--parentflag, and a client-side depth guard (the server already enforces it).🤖 Generated with Claude Code