async-python-patterns
Python-Async-Patterns meistern
Der Aufbau von Async-Anwendungen in Python erfordert das Verständnis komplexer Muster für parallele Ausführung, Aufgabenverwaltung und Leistungsoptimierung. Diese Skill bietet umfassende Anleitung zu asyncio-Grundlagen, praxisnahen Mustern und Best Practices für den Aufbau leistungsstarker nicht blockierender Systeme.
スキルZIPをダウンロード
Claudeでアップロード
設定 → 機能 → スキル → スキルをアップロードへ移動
オンにして利用開始
テストする
「async-python-patterns」を使用しています。 How do I prevent blocking the event loop when running CPU-intensive tasks in async Python code?
期待される結果:
- Use asyncio.to_thread() (Python 3.9+) or loop.run_in_executor() to offload blocking CPU work to a thread pool
- Never use time.sleep() in async code - use await asyncio.sleep() instead
- Example pattern: wrap CPU-intensive functions with run_in_executor to keep the event loop responsive
「async-python-patterns」を使用しています。 What is the difference between asyncio.create_task() and asyncio.gather()?
期待される結果:
- create_task() schedules a single coroutine to run soon, returning a Task object you can await later
- gather() runs multiple coroutines concurrently and waits for all to complete, returning results as a list
- Use create_task() when you need to manage individual tasks; use gather() for fire-and-forget concurrent execution
「async-python-patterns」を使用しています。 How do I implement a timeout for an async function that might hang?
期待される結果:
- Use asyncio.wait_for() to wrap your async call with a timeout value
- Catch asyncio.TimeoutError to handle timeout scenarios gracefully
- Example: result = await asyncio.wait_for(async_operation(), timeout=5.0)
セキュリティ監査
安全Pure educational documentation containing Python asyncio code examples. All static findings are false positives from the analyzer misinterpreting markdown code blocks and documentation text. No executable code, scripts, network calls, file operations, or external commands exist in this skill.
リスク要因
⚙️ 外部コマンド (56)
🌐 ネットワークアクセス (10)
📁 ファイルシステムへのアクセス (1)
品質スコア
作れるもの
Async-Web-APIs bauen
Lerne Muster für die Erstellung leistungsstarker Async-APIs mit FastAPI, aiohttp oder Sanic
Parallele I/O-Operationen
Implementiere effiziente parallele Datenbank-, Datei- und Netzwerkoperationen ohne Blockierung
Echtzeit-Anwendungen
Entwickle WebSocket-Server, Chat-Systeme und ereignisgesteuerte Anwendungen
これらのプロンプトを試す
Show me how to use asyncio.gather() to run multiple async functions concurrently in Python
How do I properly handle errors and timeouts when using asyncio.wait_for() in Python
Explain how to use asyncio.Semaphore to rate limit concurrent API calls in Python
Show me an example of the producer-consumer pattern using asyncio.Queue for processing items concurrently
ベストプラクティス
- Verwende immer asyncio.run() als Einstiegspunkt für Async-Programme (Python 3.7+)
- Nutze asyncio.gather() für die parallele Ausführung unabhängiger Async-Operationen
- Implementiere korrektes Timeout-Handling mit asyncio.wait_for(), um hängende Operationen zu verhindern
回避
- Async-Funktionen ohne await aufrufen – das gibt ein Coroutine-Objekt zurück, statt die Funktion auszuführen
- Blockierende Operationen wie time.sleep() oder CPU-intensive Arbeit direkt im Async-Code verwenden
- Synchronen und asynchronen Code ohne korrekte Übersetzung mit asyncio.run() mischen