async-python-patterns-5ca4dc — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited async-python-patterns-5ca4dc (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
事件循环是 asyncio 的核心,管理和调度异步任务。
使用 async def 定义的可暂停和恢复的函数。
在事件循环上并发运行的已调度协程。
表示异步操作最终结果的底层对象。
import asyncio
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
asyncio.run(main())async def fetch_all_users(user_ids: List[int]) -> List[dict]:
tasks = [fetch_user(uid) for uid in user_ids]
results = await asyncio.gather(*tasks)
return resultstry:
result = await asyncio.wait_for(slow_operation(5), timeout=2.0)
except asyncio.TimeoutError:
print("Operation timed out")async def api_call(url: str, semaphore: asyncio.Semaphore) -> dict:
async with semaphore:
await asyncio.sleep(0.5)
return {"url": url, "status": 200}
async def rate_limited_requests(urls: List[str], max_concurrent: int = 5):
semaphore = asyncio.Semaphore(max_concurrent)
tasks = [api_call(url, semaphore) for url in urls]
return await asyncio.gather(*tasks)# 错误 - 返回协程对象,不执行
result = async_function()
# 正确
result = await async_function()# 错误 - 阻塞
import time
async def bad():
time.sleep(1)
# 正确 - 非阻塞
async def good():
await asyncio.sleep(1)# 正确方式
def sync_function():
result = asyncio.run(async_function())~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.