用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill maverick-python-async命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | maverick-python-async |
| description | Python async/await patterns and asyncio best practices Use when this capability is needed. |
| metadata | {"author":"get2knowio"} |
Expert guidance for asynchronous Python programming with asyncio.
async def fetch_data(url: str) -> dict:
"""Async function returns a coroutine."""
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
import asyncio
# Python 3.7+
asyncio.run(main())
# Or event loop (older style)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
# gather - run concurrently, wait for all
results = await asyncio.gather(
fetch_data(url1),
fetch_data(url2),
fetch_data(url3),
)
# create_task - run in background
task1 = asyncio.create_task(fetch_data(url1))
task2 = asyncio.create_task(fetch_data(url2))
result1 = await task1
result2 = await task2
try:
result = await asyncio.wait_for(
slow_operation(),
timeout=5.0
)
except asyncio.TimeoutError:
print("Operation timed out")
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data = await response.text()
async for item in async_generator():
process(item)
# BAD - blocks event loop
async def bad():
time.sleep(1) # BLOCKS!
response = requests.get(url) # BLOCKS!
# GOOD - use async alternatives
async def good():
await asyncio.sleep(1)
async with aiohttp.ClientSession() as session:
response = await session.get(url)
# BAD - coroutine never executes
async def bad():
fetch_data() # Missing await!
# GOOD
async def good():
await fetch_data()
# BAD - creates 10000 tasks at once
tasks = [asyncio.create_task(fetch(url)) for url in urls]
# GOOD - use semaphore to limit concurrency
async def fetch_with_limit(url, semaphore):
async with semaphore:
return await fetch(url)
semaphore = asyncio.Semaphore(10)
tasks = [fetch_with_limit(url, semaphore) for url in urls]
Converted and distributed by TomeVault — claim your Tome and manage your conversions.