Skip to content
Back to skills

Py Async

ASecurity

Convert blocking Python code to async/await without deadlocks or hidden sync calls

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentspythongo

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill py-async --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Py Async?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Py Async
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-py-async/badge)](https://www.skillsdirectory.com/skills/black141312-py-async)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: py-async
description: Convert blocking Python code to async/await without deadlocks or hidden sync calls
category: languages
---

# Py Async

Use this when a module's I/O latency dominates and you want to move it to `asyncio`, or when porting sync callers into an existing async stack.

1. Map the blocking boundaries: identify every network, disk, subprocess, and `time.sleep` call — these become `await` points or run in an executor.
2. Swap sync libraries for async equivalents (`requests`→`httpx`/`aiohttp`, `psycopg2`→`asyncpg`, `open`→`aiofiles`) rather than wrapping everything in threads.
3. Convert functions to `async def` from the I/O leaves upward, propagating `await` to every caller until you reach an entry point.
4. For unavoidable blocking calls (CPU work, sync-only libs), offload with `await asyncio.to_thread(fn, ...)` or a process pool — don't call them directly on the loop.
5. Replace sequential awaits with `asyncio.gather` or `TaskGroup` where operations are independent, and guard shared state with `asyncio.Lock`.
6. Run under load and check for "coroutine was never awaited" warnings, blocked-loop stalls, and unhandled task exceptions.

## Rules
- Never call a blocking function directly inside a coroutine — it stalls the entire event loop for all tasks.
- One event loop per process: use `asyncio.run(main())` at the top; don't create nested loops or call `loop.run_until_complete` from within async code.
- Cancellation is cooperative — propagate `CancelledError`, and put cleanup in `finally` or `async with`.
- Set timeouts on every await that hits the network (`asyncio.timeout(...)`); an unbounded await is a hang waiting to happen.
- Don't mix sync and async versions of the same function in one call graph — pick a color and commit to it.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.