Skip to content

MonitorTracker

Polls one item checkpoint directory, tracking per-worker change.

Staleness is judged by this tracker's own clock: once a change in a worker's progress has been observed, an in-flight worker is stale when nothing has changed for stale_after seconds. Before any change has been observed, the worker's heartbeat age (by wall_clock) is used.

Parameters:

Name Type Description Default
directory Path | str

The item_checkpoint_dir to scan.

required
stale_after float

Seconds without change before an in-flight worker is stale.

DEFAULT_STALE_AFTER
clock Callable[[], float]

Monotonic clock for change tracking.

monotonic
wall_clock Callable[[], float]

Wall clock compared against workers' heartbeat timestamps.

time

MonitorTracker

MonitorTracker(directory: Path | str, *, stale_after: float = DEFAULT_STALE_AFTER, clock: Callable[[], float] = time.monotonic, wall_clock: Callable[[], float] = time.time) -> None

Name Type Description Default
directory Path | str

The item_checkpoint_dir to scan.

required
stale_after float

Seconds without change before an in-flight worker is stale.

DEFAULT_STALE_AFTER
clock Callable[[], float]

Monotonic clock for change tracking.

monotonic
wall_clock Callable[[], float]

Wall clock compared against workers' heartbeat timestamps.

time

poll

poll() -> MonitorSnapshot

Read every worker ledger once and return a MonitorSnapshot.