2.4 KiB
2.4 KiB
name, description
| name | description |
|---|---|
| python-anyio-async | Use when working on Python async code in repositories that already use or are explicitly standardizing on anyio. Apply task-group, cancellation, timeout, and async-boundary patterns without migrating established asyncio, trio, or synchronous code unless requested. |
Python AnyIO Async
Use this skill for anyio-based async implementation work. It is not a general license to rewrite a repository's async model.
Priority Order
- Explicit user instructions
- Existing repository async conventions and verification workflow
- This skill
Only apply this skill when the repository already uses anyio or the user explicitly asks to standardize on it.
Before Applying This Skill
Check the local project first:
- existing async imports and helpers
- current task runner and verification commands
- whether the code is
anyio,asyncio,trio, or sync-only - whether the CLI entrypoint is already established
If the repository is built around asyncio, trio, or synchronous code, keep that model unless the user asks for a migration.
Defaults
- Prefer
anyio.create_task_group()over manual task orchestration. - Prefer
anyio.fail_after()or cancellation scopes for time-bounded work. - Use
anyiostreams and synchronization primitives instead of mixing in rawasyncioAPIs. - For async CLIs that already use
anyio, keep a synchronous entrypoint that callsanyio.run(...). - When an
asyncioboundary is unavoidable, isolate it and leave a short note.
from pathlib import Path
import anyio
import click
@click.command()
@click.argument("config_path", type=click.Path(path_type=Path))
def main(config_path: Path) -> None:
anyio.run(run, config_path)
async def run(config_path: Path) -> None:
async with await anyio.open_file(config_path) as fh:
_ = await fh.read()
Verification
Use the repository's existing verification workflow first.
If no local workflow exists and the repository is already aligned with this stack:
- run the configured type checker
- run the async test suite or
pytest - run a CLI or module smoke test that exercises the async boundary when relevant
Anti-Goals
- Do not replace an established
asyncioortriocodebase withanyiounless asked. - Do not mix manual event-loop management into
anyiocode without a forced integration boundary. - Do not use this skill for synchronous code just because it contains a small async helper.