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
812 B
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 deffunction. - 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(),pathlibfile operations, or synchronous clients), wrap the blocking call inasyncio.to_threadto 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)