async-python-patterns

Solid

Use when writing Python asyncio code — picking between gather / TaskGroup / wait, structured concurrency, timeouts, cancellation, sync-bridging — decision framework only, cookbook externalized.

AI & Automation 7 stars 1 forks Updated today MIT

Install

View on GitHub

Quality Score: 81/100

Stars 20%
30
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# async-python-patterns Decision framework for picking the right Python asyncio primitive. **The pattern cookbook lives upstream** (links in § Provenance) — this skill is the predicate, not the recipe library. Sunset-policy compliant: the 600+ lines of language-specific cookbook stay in authoritative Python docs. ## When to use - Designing a new async I/O-bound service (FastAPI, aiohttp, async DB client). - Reviewing a diff that introduces `asyncio.gather`, `asyncio.create_task`, `TaskGroup`, `as_completed`, or `wait_for`. - Mixing sync and async code (calling sync libs from async context, or vice versa). - Diagnosing event-loop blocking, never-awaited warnings, or cancellation leaks. Do NOT use when: - The work is CPU-bound — async will not help; route to multiprocessing or threadpool. - The runtime is not Python — read the host runtime's concurrency guide. - The fix is a single missing `await` — read the upstream tutorial directly. ## Decision framework ### Step 1 — Verify async is the right tool ``` Workload is: I/O-bound, many concurrent waits → async fits (network, disk, IPC). CPU-bound (parsing, math, crypto) → async is wrong; use ProcessPoolExecutor. Mixed → async shell + run_in_executor for CPU bursts. Single sequential call → don't introduce async; sync is simpler. ``` ### Step 2 — Pick the concurrency primitive ``` Run N independent coroutines, ALL must complete: Same trust level, exceptions cancel siblin...

Details

Author
event4u-app
Repository
event4u-app/agent-config
Created
3 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category