Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Developer tools

Python asyncio: adopt async only for concurrent I/O needs

Design event-loop behavior, task concurrency, cancellation, timeouts, and blocking-work offload.

Skills

Estimate concurrent network/database I/O versus CPU work first; a low-concurrency script may be simpler synchronously. If using asyncio, keep the call path async, use async clients and pooled connections, and avoid blocking the event loop. Bound tasks with TaskGroup/semaphores, propagate cancellation/errors, and time out external calls. Offload CPU-heavy work with `asyncio.to_thread()` or a process pool. Test cancellation, cleanup, and slow dependencies, and use measurements to justify throughput gains.

Permissions

Prerequisites

Permissions

Limitations

Keep call paths consistently sync or async; offload CPU work and propagate cancellation/errors to task owners.

Pinned upstream source

https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/python-development/skills/async-python-patterns/SKILL.md

Repository
wshobson/agents
File path
plugins/python-development/skills/async-python-patterns/SKILL.md
Pinned commit
46891e7e60da0e52baf1050b7b6391b64e84c6d9
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Compatible tools

asyncio event loop · pytest-asyncio · Thread/process executors

View skill directory

Main topic

Take a coding Agent change from context to verification

Related resources