← ClaudeAtlas

async-python-patternslisted

Python asyncio and concurrent programming patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.
NickCrew/Claude-Cortex · ★ 15 · AI & Automation · score 77
Install: claude install-skill NickCrew/Claude-Cortex
# Async Python Patterns Expert guidance for implementing asynchronous Python applications using asyncio, concurrent programming patterns, and async/await for building high-performance, non-blocking systems. ## When to Use This Skill - Building async web APIs (FastAPI, aiohttp, Sanic) - Implementing concurrent I/O operations (database, file, network) - Creating web scrapers with concurrent requests - Developing real-time applications (WebSocket servers, chat systems) - Processing multiple independent tasks simultaneously - Optimizing I/O-bound workloads requiring parallelism - Implementing async background tasks and task queues ## Core Patterns ### 1. Basic Async/Await **Foundation for all async operations:** ```python import asyncio async def fetch_data(url: str) -> dict: """Fetch data asynchronously.""" await asyncio.sleep(1) # Simulate I/O return {"url": url, "data": "result"} async def main(): result = await fetch_data("https://api.example.com") print(result) asyncio.run(main()) ``` **Key concepts:** - `async def` defines coroutines (pausable functions) - `await` yields control back to event loop - `asyncio.run()` is the entry point (Python 3.7+) - Single-threaded cooperative multitasking ### 2. Concurrent Execution with gather() **Execute multiple operations simultaneously:** ```python import asyncio from typing import List async def fetch_user(user_id: int) -> dict: await asyncio.sleep(0.5) return {"id": user_id, "name": f"User {