Files
google--adk-python/.agents/skills/adk-style/references/async.md
T
wehub-resource-sync ec2b666284
Continuous Integration / Pre-commit Linter (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.10) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.11) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.12) (push) Waiting to run
Continuous Integration / Mypy Check (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.10) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.11) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.12) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.13) (push) Waiting to run
Continuous Integration / Unit Tests (Python 3.14) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Waiting to run
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Waiting to run
Copybara PR Handler / close-imported-pr (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:25:13 +08:00

812 B

Async and Concurrency Style Guide

  • All I/O operations must be in async functions: Any operation that performs I/O (network calls, file system access, database queries, etc.) must be defined in an async def function.
  • Do not block the event loop: Avoid calling blocking synchronous functions directly from async code.
  • Wrap synchronous I/O: If you must use a synchronous library for I/O (e.g., standard open(), pathlib file operations, or synchronous clients), wrap the blocking call in asyncio.to_thread to run it in a separate thread and prevent blocking the main event loop.

Example:

async def save_data(path: Path, data: bytes) -> None:
  # Wrap blocking file write in asyncio.to_thread
  await asyncio.to_thread(path.write_bytes, data)