dorm.contrib.task_pool¶
Per-asyncio.Task pool connection pinning + concurrency-safety guard.
API¶
dorm.contrib.task_pool.pinned_connection(*, using: str = 'default')
async
¶
Pin one async pool connection to the current task. See module docstring for usage and rationale.
dorm.contrib.task_pool.assert_no_concurrent_gather() -> None
¶
Raise RuntimeError when called inside two asyncio.gather
siblings that share a pinned connection. Useful as a self-check
inside backend code that knows it is about to issue a query.
dorm.contrib.task_pool.get_pinned_connection() -> Any | None
¶
Return the currently pinned async connection, or None.
Backends call this from their async _choose_conn so that an
active aatomic() connection still wins (transactions take
precedence over pinning) but otherwise the pinned connection is
used.