python-async-patterns
Skill2 starsChanged 10 months agoMITView on GitHub
Modern asynchronous programming with asyncio. Use this skill when building async applications, need concurrent I/O operations, or migrating from sync to async code. Covers async/await syntax, asyncio patterns, aiohttp, async context managers, and common pitfalls.
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 120
When to use threads vs async
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Async Patterns
Modern asynchronous programming patterns with asyncio for Python 3.7+.
Core Concepts
Async programming is for I/O-bound concurrency, not CPU-bound parallelism
Good use cases:
- HTTP requests (API calls, web scraping)
- Database queries
- File I/O
- Network operations
Bad use cases:
- CPU-intensive calculations (use multiprocessing)
- Simple sequential operations
Basic Async/Await
import asyncio
async def fetch_data(url: str) -> dict:
await asyncio.sleep(1) # Simulate I/O
return {"url": url, "data": "..."}
async def main():
result = await fetch_data("https://example.com")
# Run multiple coroutines concurrently
results = await asyncio.gather(
fetch_data("url1"),
fetch_data("url2"),
fetch_data("url3")
)
asyncio.run(main())Concurrent Execution Patterns
asyncio.gather() - Run Multiple Tasks
async def process_urls(urls):
tasks = [fetch_data(url) for url in urls]
results = await asyncio.gather(*tasks)
return resultsSee concurrent-execution-patterns.md for:
- TaskGroup (3.11+)
- Timeout handling
- Semaphores for rate limiting
Async HTTP with aiohttp
import aiohttp
async def fetch_json(session, url):
async with session.get(url) as response:
return await response.json()
async def main():
async with aiohttp.ClientSession() as session:
results = await asyncio.gather(
fetch_json(session, "url1"),
fetch_json(session, "url2")
)See aiohttp-patterns.md for:
- POST requests with JSON
- Error handling
- Connection pooling
- Streaming responses
Async Context Managers
from contextlib import asynccontextmanager
@asynccontextmanager
async def get_session():
session = aiohttp.ClientSession()
try:
yield session
finally:
await session.close()Mixing Sync and Async Code
import concurrent.futures
async def main():
loop = asyncio.get_event_loop()
# Run blocking code in thread pool
result = await loop.run_in_executor(
None,
blocking_function,
arg1, arg2
)See sync-async-interop.md for:
- When to use threads vs async
- Event loop management
- Bridging sync and async libraries
Common Pitfalls
See async-pitfalls.md for:
- Forgetting to await
- Blocking the event loop
- Not closing resources
- Race conditions
When NOT to Use Async
- CPU-bound work (use multiprocessing)
- Simple sequential operations
- Limited external I/O
- Library ecosystem doesn't support async
source: asyncio documentation
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- FullFran/Agent-skills-POC★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository38 other files it gives its agents.
- Data Engineering Cloud InfrastructureSkill
- data-eng-data-qualitySkill
- data-eng-streaming-patternsSkill
- data-eng-testing-patternsSkill
- data-eng-warehouse-patternsSkill
- DevOps CI/CD PatternsSkill
- devops-docker-patternsSkill
- devops-monitoring-observabilitySkill
- devops-terraform-patternsSkill
- git-advanced-operationsSkill
- git-workflow-patternsSkill
- modern-python-patternsSkill
- python-api-developmentSkill
- python-data-pipelinesSkill
- python-data-wranglingSkill
- python-devops-automationSkill
- python-error-handlingSkill
- python-package-developmentSkill
- python-performanceSkill
- python-testingSkill
- customizing-vectors-rSkill
- designing-oop-rSkill
- developing-packages-rSkill
- metaprogramming-rlangSkill
- optimizing-rSkill
- writing-tidyverse-rSkill
- sql-advanced-featuresSkill
- sql-analytics-patternsSkill
- sql-data-modelingSkill
- SQL Integration PatternsSkill
- sql-query-fundamentalsSkill
- sql-query-optimizationSkill
- sql-transformationsSkill
- API DesignSkill
- webdev-html-css-patternsSkill
- webdev-javascript-fundamentalsSkill
- webdev-react-patternsSkill
- webdev-typescript-patternsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

