async-await-checker

Enforce correct async/await patterns in Python functions using asyncio.

2|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill async-await-checker
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-await-checker
Source: https://github.com/ricardoroche/ricardos-claude-code/tree/main/.claude/skills/async-await-checker
Command: npx skills add https://github.com/ricardoroche/ricardos-claude-code --skill async-await-checker

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires httpx, aiofiles, pytest.

What problem does it solve?

This Skill enforces correct async/await patterns in Python, preventing common asyncio.run() errors within an already-running event loop and ensuring efficient non-blocking I/O. It helps developers write high-performance, concurrent applications without introducing subtle bugs.

Core Features & Use Cases

  • Core async/await Usage: Guides on using async def for functions that perform asynchronous operations and await for calling them.
  • Parallel Execution: Provides patterns for running multiple asynchronous tasks concurrently using asyncio.gather().
  • Async I/O Operations: Shows examples for asynchronous database queries, HTTP requests (with httpx), and file I/O (with aiofiles).
  • Error Handling & Testing: Covers robust error handling in async code and testing async functions with pytest.mark.asyncio.
  • Use Case: A FastAPI application needs to fetch data from multiple external APIs concurrently. This skill helps the developer use asyncio.gather() to make these HTTP requests in parallel, significantly reducing the total response time of the API endpoint.

Quick Start

Refactor the fetch_user_data function to be asynchronous and use await for database calls.

Frequently Asked Questions about async-await-checker

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid asyncio.run() errors when calling async functions in FastAPI?

asyncio.run() creates a new event loop and fails if one is already running. In FastAPI and other async frameworks, use await directly in async def functions instead. The framework manages the event loop; asyncio.run() is only for script entry points.

How do I make concurrent HTTP requests with httpx in Python?

Use async def with httpx.AsyncClient and asyncio.gather() to run multiple requests in parallel. Gather accepts a list of awaited tasks and returns results concurrently, reducing total response time compared to sequential await calls.

What's the difference between await and asyncio.run() in async code?

await suspends a function until an async operation completes while keeping the event loop running. asyncio.run() creates and runs a new event loop, suitable only at program start; it fails if an event loop already exists.

How do I test async functions with pytest?

Mark test functions with @pytest.mark.asyncio to run them as coroutines. This allows you to use await inside tests and properly handle async fixtures, integrating async code testing into your standard pytest workflow.

Can I use async with for file I/O in Python?

Yes, use aiofiles for asynchronous file operations with async with context managers. This prevents blocking the event loop during disk I/O, keeping your application responsive for concurrent tasks.

Why does my async function fail when I call a sync function inside it?

Sync functions block the event loop, preventing other async tasks from running and causing performance degradation or timeouts. Replace them with async equivalents like httpx for HTTP or aiofiles for file I/O to maintain non-blocking execution.