957 B
957 B
| paths | ||
|---|---|---|
|
Async programming rule
The write/read paths are async end-to-end. Keep them non-blocking.
- No blocking calls in async functions — no synchronous file I/O, no
time.sleep, no blocking DB/network calls insideasync def. RuffASYNCflags the common cases. - Offload CPU/blocking work with
anyio.to_thread.run_sync(or the established helper) rather than blocking the event loop. - Concurrency via
asyncio.gather/asyncio.TaskGroupfor independent awaits; don'tawaitin a loop when the calls are independent. - Tests:
pytest-asynciois inautomode — anasync def test_*just works, no@pytest.mark.asyncioneeded. - Don't fire-and-forget without holding a reference (
asyncio.create_taskresults must be tracked, or you lose exceptions). The OME subsystem owns the long-running background loops — application code shouldn't spawn its own.