Local Turn Lock • AI Agent SDK

LocalTurnLock: Default in-process turn lock — today's “asyncio.Lock“ behaviour.

LocalTurnLock

Defined in the protocols module.

AI Agent

Default in-process turn lock — today’s `asyncio.Lock` behaviour.

Zero-cost, dependency-free implementation of :class:TurnLockProtocol for single-replica / no-backend deployments. It serialises turns within one process (per event loop) exactly as the existing `LockMap does, so upgrading is byte-for-byte backward compatible. It provides no cross- process guarantee — selecting a distributed backend (e.g. redis`) is what extends serialisation across replicas.

The `owner/ttl arguments are accepted for protocol symmetry but are inert here: an in-process asyncio.Lock` is released deterministically when the holding task exits, so there is no crashed-holder lease to expire.

Methods

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 7409