async-python-patterns
Skill by wshobson
Guides an AI assistant through writing async Python with asyncio, including gather(), tasks, timeouts and error handling. Intended for developers building async APIs, concurrent systems and I/O-bound applications.
Install async-python-patterns
Built from the published package, never by AI.
git clone --depth 1 https://github.com/wshobson/agents /tmp/agents && mkdir -p ~/.claude/skills && cp -r /tmp/agents/plugins/python-development/skills/async-python-patterns ~/.claude/skills/async-python-patternsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/wshobson/agents /tmp/agents && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/agents/plugins/python-development/skills/async-python-patterns ~/.gemini/antigravity-cli/skills/async-python-patternsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install async-python-patterns in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
The async-python-patterns skill gives an AI assistant guidance on writing asynchronous Python with asyncio, concurrent programming and async/await. It covers core concepts such as the event loop, coroutines, tasks, futures, async context managers and async iterators. It also shows fundamental patterns for concurrent execution with gather(), task creation, error handling and timeout handling.
It includes a decision guide comparing asyncio with multiprocessing, thread pools and sync code, plus common pitfalls such as forgetting await, blocking the event loop and mishandling cancellation. Testing examples use pytest-asyncio. The source says it suits building async web APIs, concurrent systems, web scrapers, real-time applications and I/O-bound workloads. Advanced examples are in a separate reference file.
Written from the project's SKILL.md and checked against it.
What it can do
- Basic async/awaitShows how to define and await coroutines with async def and await.
- Concurrent execution with gather()Runs multiple coroutines concurrently, such as fetching several users at once.
- Task creation and managementCreates background tasks with asyncio.create_task and waits for their results.
- Error handling in async codeWraps failing coroutines and uses gather() with return_exceptions to filter failures.
- Timeout handlingLimits how long an operation runs using asyncio.wait_for.
- Sync vs async decision guideCompares asyncio, multiprocessing, thread pools and sync code by use case.
- Common pitfallsCovers forgetting await, blocking the event loop, cancellation and mixing sync and async code.
- Testing async codeShows how to write async tests with pytest-asyncio and pytest.mark.asyncio.
What you need
- Python 3.7 or later
- pytest-asyncio for the testing examples
Try asking
- Show me how to fetch several URLs concurrently with asyncio.gather()
- Help me add a timeout to an async function using asyncio.wait_for
- Should I use asyncio or multiprocessing for my CPU-heavy script?
Good to know
- Advanced patterns are in a separate reference file, not in the main skill text.
- The source advises staying sync for simple scripts with few connections.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: plugins/python-development/skills/async-python-patterns/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md7 KB -
references/details.md12 KB
Alternatives to async-python-patterns
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
async-python-patterns: common questions
When should I use asyncio instead of threads or multiprocessing?
The source recommends asyncio for many concurrent network or database calls. It recommends multiprocessing or a thread pool for CPU-bound computation.
How do I test async Python code with this skill?
The skill shows tests marked with @pytest.mark.asyncio using pytest-asyncio. It also shows testing a timeout with pytest.raises.
Where are the advanced async patterns?
The skill says detailed sections starting with Advanced Patterns live in references/details.md. The assistant reads that file when the summary is not enough.
How do I install async-python-patterns?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is async-python-patterns free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is async-python-patterns safe to use?
It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to async-python-patterns?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
