Skip to content

aiskillstore/marketplace / skills/0xdarkmatter/python-async-patterns

python-async-patterns

Verified

Python asyncio patterns for concurrent programming. Triggers on: asyncio, async, await, coroutine, gather, semaphore, TaskGroup, event loop, aiohttp, concurrent.

scripts/find-blocking-calls.sh

View on GitHub
#!/bin/bash
# Find potentially blocking calls in async Python code
# Usage: ./find-blocking-calls.sh [directory]

DIR="${1:-.}"

echo "=== Scanning for blocking calls in async code ==="
echo "Directory: $DIR"
echo

# time.sleep() in async functions
echo "--- time.sleep() in async functions ---"
rg -n "async def" -A 20 "$DIR" | rg "time\.sleep\(" || echo "None found"
echo

# requests library (blocking HTTP)
echo "--- requests library usage ---"
rg -n "import requests|from requests" "$DIR" --type py || echo "None found"
echo

# Blocking file operations
echo "--- Blocking file operations in async ---"
rg -n "async def" -A 30 "$DIR" | rg "open\(|\.read\(\)|\.write\(" || echo "None found"
echo

# subprocess without asyncio
echo "--- Blocking subprocess calls ---"
rg -n "subprocess\.(run|call|check_output)" "$DIR" --type py || echo "None found"
echo

# socket operations
echo "--- Blocking socket operations ---"
rg -n "socket\.(socket|create_connection)" "$DIR" --type py || echo "None found"
echo

# input() calls
echo "--- Blocking input() calls ---"
rg -n "\binput\(" "$DIR" --type py || echo "None found"
echo

echo "=== Recommendations ==="
echo "- Replace time.sleep() with asyncio.sleep()"
echo "- Replace requests with aiohttp or httpx"
echo "- Replace open() with aiofiles"
echo "- Replace subprocess with asyncio.create_subprocess_exec()"
echo "- Use asyncio.get_event_loop().run_in_executor() for blocking code"
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 319kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 319kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 319kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 319kUpdated Claude CodeCodexVerifiedInstall