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

python
def ensure_run_lock(obj) -> Any

Parameters

ParamField Any

The orchestration instance (AgentTeam or Workflow) whose per-instance _run_lock should be returned, creating it on first access.

Returns

ResponseField Any

The instance’s _run_lock — the same object for every caller under a concurrent first-access race.

Uses

  • getattr
  • threading.Lock

Source

View on GitHub

praisonaiagents/_run_lock.py at line 18


Related Documentation