Skip to content

docsy(v2): async programming overview#1214

Open
ppiegaze wants to merge 2 commits into
mainfrom
docsy/v2-async-education
Open

docsy(v2): async programming overview#1214
ppiegaze wants to merge 2 commits into
mainfrom
docsy/v2-async-education

Conversation

@ppiegaze

Copy link
Copy Markdown
Collaborator

What

New task-programming page: Structured concurrency with anyio (content/user-guide/task-programming/structured-concurrency-anyio.md).

Teaches anyio task groups (anyio.create_task_group() + aioresult.ResultCapture) as a top-level structured-concurrency alternative to raw asyncio, grounded in the SDK's examples/advanced/use_anyio.py. Covers the fanout pattern, structured cancellation semantics (cancel siblings on failure for free), and when to prefer anyio over asyncio.gather.

Why — DOC-1107 residual scoping

DOC-1107 ("Async education") asked for three things: (1) asyncio.gather vs asyncio.create_task, (2) async task cancellation, (3) anyio as a top-level API. A recent async-docs grind absorbed the first two, so this PR covers only the genuine residual:

Ask Status Covered by
gather vs create_task already covered task-dependencies.md (#1210) — "Dependency-driven scheduling" reproduces the exact create_task pattern
async cancellation already covered abort-tasks.md — "Canceling actions programmatically" (uses cancel_tasks.py)
conceptual why-async already covered migration/flyte-2/async.md ("Asynchronous model")
anyio this PR grounded in examples/advanced/use_anyio.py — no prior coverage

Relationship to sibling async pages

Part of the same async-education cluster; cross-links (not duplicates) fanout.md, controlling-parallelism.md, task-dependencies.md, and abort-tasks.md. Follows the sibling pages' convention: inline ```python code blocks (no unionai-examples fragment 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

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>
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

GHA build & deploy preview

Built by .github/workflows/build-pr.yml and deployed to the docs CF Pages project by .github/workflows/deploy-pr-preview.yml.

Branch alias https://pr-1214-docsy-v2-async-educa.docs-dog.pages.dev
This commit https://0bb8a346.docs-dog.pages.dev
Commit SHA 9088ba32cca37ef1a373509093a613d20962aa00

Updated automatically on every push.

@ppiegaze ppiegaze marked this pull request as ready for review July 13, 2026 14:13
@ppiegaze ppiegaze requested a review from EngHabu as a code owner July 13, 2026 14:13
Copilot AI review requested due to automatic review settings July 13, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 anyio vs asyncio.

💡 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants