Install the skill above, then run this in your AI tool:
/async-python-patterns <your description>
About
Comprehensive guidance for implementing asynchronous Python applications using asyncio, concurrent programming patterns, and async/await for building high-performance, non-blocking systems.
Source
What gets added to your project
Preview every file this package writes on install before you run the command above.
Summary
Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.
Skill instructions
Async Python Patterns
Comprehensive guidance for implementing asynchronous Python applications using asyncio, concurrent programming patterns, and async/await for building high-performance, non-blocking systems.
import asyncio
from typing importList, Optionalasyncdefrisky_operation(item_id: int) -> dict:
"""Operation that might fail."""await asyncio.sleep(0.1)
if item_id % 3 == 0:
raise ValueError(f"Item {item_id} failed")
return {"id": item_id, "status": "success"}
asyncdefsafe_operation(item_id: int) -> Optional[dict]:
"""Wrapper with error handling."""try:
returnawait risky_operation(item_id)
except ValueError as e:
print(f"Error: {e}")
returnNoneasyncdefprocess_items(item_ids: List[int]):
"""Process multiple items with error handling."""
tasks = [safe_operation(iid) for iid in item_ids]
results = await asyncio.gather(*tasks, return_exceptions=True)
# Filter out failures
successful = [r for r in results if r isnotNoneandnotisinstance(r, Exception)]
failed = [r for r in results if r isNoneorisinstance(r, Exception)]
print(f"Success: {len(successful)}, Failed: {len(failed)}")
return successful
asyncio.run(process_items([1, 2, 3, 4, 5, 6]))
Pattern 5: Timeout Handling
python
import asyncio
asyncdefslow_operation(delay: int) -> str:
"""Operation that takes time."""await asyncio.sleep(delay)
returnf"Completed after {delay}s"asyncdefwith_timeout():
"""Execute operation with timeout."""try:
result = await asyncio.wait_for(slow_operation(5), timeout=2.0)
print(result)
except asyncio.TimeoutError:
print("Operation timed out")
asyncio.run(with_timeout())
Detailed worked examples and patterns
Detailed sections (starting with ## Advanced Patterns) live in references/details.md. Read that file when the navigation summary above is insufficient.
Common Pitfalls
1. Forgetting await
python
# Wrong - returns coroutine object, doesn't execute
result = async_function()
# Correct
result = await async_function()
Add this badge to a GitHub README so readers can open the package page and install the same version.
[](https://www.aipm-registry.com/skills/wshobson/async-python-patterns/1.0.0?utm_source=github&utm_medium=readme&utm_campaign=package_badge)
This imported publisher has not claimed its AIPM account. A connected account confirms account control, but it does not guarantee that a package is safe.
AI assistant context
What this skill is for
@wshobson/async-python-patterns@1.0.0 is an AIPM skill package for All tools. Use it when a project needs the reusable AI behavior described as: Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.
Run aipm add @wshobson/async-python-patterns@1.0.0 in a project that has AIPM initialized.
Supported tools
@wshobson/async-python-patterns@1.0.0 supports All tools.
Before installing
AIPM skills can add files to your project. Review the package name, target, description, license, and publisher before installing. Use a clean branch when trying a new skill.