Skip to content

API Reference parrot.scheduler.coordination

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.scheduler.coordination

View source

Cross-worker fire coordination for the agent scheduler (FEAT-631).

Alias CACHE_HOST

Re-exported from parrot.conf.CACHE_HOST.

Alias CACHE_PORT

Re-exported from parrot.conf.CACHE_PORT.

Attribute CURRENT_RUN_TIME

Type: ContextVar[Optional[datetime]]

Class CoordinatedAsyncIOExecutor

AsyncIOExecutor whose coroutine jobs first claim their scheduled fire.

Parameter Type Default Description
coordinator Optional[FireCoordinator] None
on_unavailable Optional[UnavailableHook] None

Method CoordinatedAsyncIOExecutor.set_coordinator

Replace the coordinator after executor construction.

set_coordinator(coordinator: FireCoordinator) -> None

Parameter Type Default Description
coordinator FireCoordinator

Attribute DEFAULT_FIRE_TTL

Attribute DEFAULT_PREFIX

Attribute DEFAULT_RUN_NOW_TTL

Class FireCoordinationError

The coordination backend could not answer.

Class FireCoordinator

Backend contract for scheduled-fire and run-now coordination.

Attributes:

Attribute Type Description
worker_id str

Method FireCoordinator.claim

claim(job_id: str, run_time: datetime) -> bool

Parameter Type Default Description
job_id str
run_time datetime

Returns: bool

Method FireCoordinator.try_acquire_running

try_acquire_running(schedule_id: str) -> bool

Parameter Type Default Description
schedule_id str

Returns: bool

Method FireCoordinator.release_running

release_running(schedule_id: str) -> None

Parameter Type Default Description
schedule_id str

Method FireCoordinator.close

close() -> None

Attribute INTERVAL_ANCHOR

Shared start_date for every interval trigger (FEAT-676, ledger aa813ccc1927).

The fire claim key embeds the scheduled due time, so all workers must compute identical due times. Anchoring interval triggers at a fixed epoch makes each fire INTERVAL_ANCHOR + n * interval on every worker, regardless of when the worker built the trigger.

Class NullFireCoordinator

Single-process coordinator: every fire claim wins.

Parameter Type Default Description
worker_id Optional[str] None

Method NullFireCoordinator.claim

Allow every scheduled fire when no shared backend is configured.

claim(job_id: str, run_time: datetime) -> bool

Parameter Type Default Description
job_id str
run_time datetime

Returns: bool

Method NullFireCoordinator.try_acquire_running

Acquire the in-process run-now guard for a schedule.

try_acquire_running(schedule_id: str) -> bool

Parameter Type Default Description
schedule_id str

Returns: bool

Method NullFireCoordinator.release_running

Release the in-process run-now guard for a schedule.

release_running(schedule_id: str) -> None

Parameter Type Default Description
schedule_id str

Method NullFireCoordinator.close

Close the coordinator; there are no local resources to release.

close() -> None

Class RedisFireCoordinator

Coordinate fires and run-now executions using Redis SET NX EX.

Parameter Type Default Description
client 'aioredis.Redis'
worker_id Optional[str] None
fire_ttl int DEFAULT_FIRE_TTL
run_now_ttl int DEFAULT_RUN_NOW_TTL
prefix str DEFAULT_PREFIX

Method RedisFireCoordinator.claim

Atomically claim one scheduled fire.

claim(job_id: str, run_time: datetime) -> bool

Parameter Type Default Description
job_id str
run_time datetime

Returns: bool

Method RedisFireCoordinator.try_acquire_running

Atomically acquire the run-now guard for a schedule.

try_acquire_running(schedule_id: str) -> bool

Parameter Type Default Description
schedule_id str

Returns: bool

Method RedisFireCoordinator.release_running

Release a run-now guard, swallowing backend shutdown failures.

release_running(schedule_id: str) -> None

Parameter Type Default Description
schedule_id str

Method RedisFireCoordinator.close

Close the Redis client without allowing shutdown errors to escape.

close() -> None

Alias SchedulerConfigError

Re-exported from parrot.scheduler.sanitize.SchedulerConfigError.

Attribute UnavailableHook

Function build_fire_coordinator

Resolve and build the fire coordinator.

A Redis jobstore (use_redis=True) always yields RedisFireCoordinator: none from the argument or SCHEDULER_COORDINATION is overridden with a WARNING (FEAT-644 AC14). prefix namespaces the claim keys.

build_fire_coordinator(mode: Optional[str] = None, *, use_redis: bool = False, prefix: str = DEFAULT_PREFIX) -> FireCoordinator

Parameter Type Default Description
mode Optional[str] None
use_redis bool False
prefix str DEFAULT_PREFIX

Returns: FireCoordinator

Raises:

  • SchedulerConfigError — If the resolved mode is unknown.

Attribute logger

Function manager_prefix

Return the Redis key prefix owned by one scheduler manager (parrot:scheduler:<name>:).

manager_prefix(registered_name: str) -> str

Parameter Type Default Description
registered_name str

Returns: str

Function redis_db

Logical Redis db for jobstore, run state and coordination (SCHEDULER_REDIS_DB, default 6).

redis_db() -> int

Returns: int

Alias sanitize_redis_settings

Re-exported from parrot.scheduler.sanitize.sanitize_redis_settings.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally