Ensure Run Lock • AI Agent SDK
ensure_run_lock: Lazily mint obj._run_lock under a shared module guard.
ensure_run_lock
Function
</div>
This function is defined in the _run_lock module.
Lazily mint obj._run_lock under a shared module guard.
getattr(obj, "_run_lock", None) works for both the dataclass-field case (Workflow) and the plain-attribute case (AgentTeam), so the behaviour is identical to the per-module implementations it replaces.
Signature
def ensure_run_lock(obj) -> AnyParameters
ParamField
AnyThe orchestration instance (AgentTeam or Workflow) whose per-instance _run_lock should be returned, creating it on first access.
Returns
ResponseField
AnyThe instance’s _run_lock — the same object for every caller under a concurrent first-access race.
Uses
getattrthreading.Lock
Source
View on GitHubpraisonaiagents/_run_lock.py at line 18