TurnLockConfig
Defined in the config module.AI Agent Configuration for cluster-wide per-turn serialisation (Issue #3643). Selects the backend for the gateway’s per-turn lock — the guarantee that only one turn runs against a given resolved session at a time. The default
"local" backend reproduces today’s in-process asyncio.Lock /
LockMap behaviour exactly (zero cost, no new dependency), so
single-replica deployments are byte-for-byte unchanged. Selecting
"redis" extends serialisation across every replica so a
horizontally-scaled gateway (replicas > 1) no longer runs concurrent
turns on one session — the concrete distributed lock lives in the
wrapper/bot package and reuses the existing RedisConfig connection and
the scheduler’s proven owner+TTL lease pattern.
This maps onto the pure core
:class:~praisonaiagents.gateway.protocols.TurnLockProtocol.
Attributes:
backend: "local" (default, in-process asyncio.Lock) or
"redis" (distributed lease, cluster-wide serialisation).
ttl: Lease time-to-live in seconds for a distributed backend. Bounds
how long a crashed holder’s lease survives before it is reclaimable,
so a dead replica cannot wedge a healthy session (fail-open /
self-healing, as the scheduler already does). Inert for "local".
url: Optional Redis URL for the "redis" backend. When omitted the
distributed lock reuses the gateway’s configured RedisConfig.
Properties
str
No description available.
float
No description available.
Optional[str]
No description available.
Methods
enabled()
Whether a distributed (cross-replica) turn lock is selected.
Internal & Generic Methods
Internal & Generic Methods
- from_dict: Create from a parsed
gateway.turn_lockmapping (tolerant of None). - to_dict: Convert to dictionary (hides sensitive URL).
Source
View on GitHub
praisonaiagents/gateway/config.py at line 605
