python-async
Original:🇺🇸 English
Translated
Consult this skill for async Python patterns and concurrency. Use when building async APIs, concurrent systems, I/O-bound applications, implementing rate limiting, async context managers. Do not use when CPU-bound optimization - use python-performance instead. DO NOT use when: testing async code - use python-testing async module.
2installs
Added on
NPX Install
npx skill4agent add athola/claude-night-market python-asyncTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Async Python Patterns
asyncio and async/await patterns for Python applications.
Quick Start
python
import asyncio
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
asyncio.run(main())When To Use
- Building async web APIs (FastAPI, aiohttp)
- Implementing concurrent I/O operations
- Creating web scrapers with concurrent requests
- Developing real-time applications (WebSockets)
- Processing multiple independent tasks simultaneously
- Building microservices with async communication
When NOT To Use
- CPU-bound optimization - use python-performance instead
- Testing async code - use python-testing async module
Modules
This skill uses progressive loading. Content is organized into focused modules:
- See - Core async/await, gather(), and task management
modules/basic-patterns.md - See - Semaphores and locks for rate limiting
modules/concurrency-control.md - See - Error handling, timeouts, and cancellation
modules/error-handling-timeouts.md - See - Context managers, iterators, producer-consumer
modules/advanced-patterns.md - See - Testing with pytest-asyncio
modules/testing-async.md - See - Web scraping and database operations
modules/real-world-applications.md - See - Common mistakes and best practices
modules/pitfalls-best-practices.md
Load specific modules based on your needs, or reference all for detailed guidance.
Exit Criteria
- Async patterns applied correctly
- No blocking operations in async code
- Proper error handling implemented
- Rate limiting configured where needed
- Tests pass with pytest-asyncio
Troubleshooting
Common Issues
RuntimeError: no current event loop
Use as the entry point. Avoid in Python 3.10+.
asyncio.run()get_event_loop()Blocking call in async context
Move sync I/O to or .
asyncio.to_thread()loop.run_in_executor()Tests hang indefinitely
Ensure pytest-asyncio is installed and test functions are decorated with .
@pytest.mark.asyncio