docsy(v2): async programming overview#1214
Open
ppiegaze wants to merge 2 commits into
Open
Conversation
Add a task-programming page teaching anyio task groups as a top-level structured-concurrency alternative to asyncio, grounded in the SDK's examples/advanced/use_anyio.py. Covers the create_task_group + aioresult.ResultCapture fanout pattern, structured cancellation semantics, and when to prefer anyio over asyncio.gather. Residual gap for DOC-1107 (async education): gather-vs-create_task and async cancellation are now covered by sibling pages (task-dependencies, abort-tasks); the conceptual why-async by migration/flyte-2/async. anyio was the one requested item with shipped grounding and no coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Peeter Piegaze <1153481+ppiegaze@users.noreply.github.com>
GHA build & deploy previewBuilt by
Updated automatically on every push. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new task-programming documentation page introducing structured concurrency with anyio task groups (plus aioresult.ResultCapture) as an alternative to asyncio patterns when authoring Flyte async tasks.
Changes:
- Introduces
structured-concurrency-anyio.md, explaining the task-group pattern with a runnable-style example. - Documents structured cancellation semantics (“cancel siblings on failure”) and guidance on when to choose
anyiovsasyncio.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2
to
+4
| title: Structured concurrency with anyio | ||
| weight: 21 | ||
| variants: +flyte +union |
| # Structured concurrency with anyio | ||
|
|
||
| Flyte builds a task's dependency graph from what you `await` — not from any particular async library. | ||
| `asyncio` is the default and the one used throughout the [Fanout](./fanout), [Controlling parallel execution](./controlling-parallelism), and [Task dependencies and ordering](./task-dependencies) guides, but it is not the only option. |
| Stay with `asyncio` when: | ||
|
|
||
| - You just need to fan out and collect results — `await asyncio.gather(...)` is simpler (see [Fanout](./fanout)). | ||
| - You need fine-grained, dependency-driven scheduling where different consumers await different producers (see [Task dependencies and ordering](./task-dependencies)). |
Add 'Structured concurrency with anyio' to the _index.md curated Execution patterns list so the new page is discoverable from the section overview, consistent with every sibling page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
New task-programming page: Structured concurrency with anyio (
content/user-guide/task-programming/structured-concurrency-anyio.md).Teaches
anyiotask groups (anyio.create_task_group()+aioresult.ResultCapture) as a top-level structured-concurrency alternative to rawasyncio, grounded in the SDK'sexamples/advanced/use_anyio.py. Covers the fanout pattern, structured cancellation semantics (cancel siblings on failure for free), and when to prefer anyio overasyncio.gather.Why — DOC-1107 residual scoping
DOC-1107 ("Async education") asked for three things: (1)
asyncio.gathervsasyncio.create_task, (2) async task cancellation, (3)anyioas a top-level API. A recent async-docs grind absorbed the first two, so this PR covers only the genuine residual:task-dependencies.md(#1210) — "Dependency-driven scheduling" reproduces the exact create_task patternabort-tasks.md— "Canceling actions programmatically" (usescancel_tasks.py)migration/flyte-2/async.md("Asynchronous model")examples/advanced/use_anyio.py— no prior coverageRelationship to sibling async pages
Part of the same async-education cluster; cross-links (not duplicates)
fanout.md,controlling-parallelism.md,task-dependencies.md, andabort-tasks.md. Follows the sibling pages' convention: inline ```python code blocks (nounionai-examplesfragment yet), weight in the async-page range.Closes DOC-1107 residual. Held as draft per docsy publish-gate (feature ships in the current SDK; ready to publish on review).
🤖 Generated with Claude Code