run_heartbeat
A progress heartbeat for a background DAG run, sent from a thread of its own.
A background run can go silent for hours inside one step, and from the outside that looks the same as a hung run. The heartbeat runs on a daemon thread rather than on the run's event loop, so it still reports while the loop is blocked, and each report says how long the loop took to answer a no-op callback and how late the report itself was.
Classes
RunProgressHeartbeat
class RunProgressHeartbeat( loop: asyncio.AbstractEventLoop, interval: float, fields: dict[str, Any], *, probe_timeout: float | None = None, clock: Callable[[], float] = <built-in function monotonic>,):Sends a DAGRunProgressEvent every interval seconds until stopped.
Use as a context manager, or call start and stop. An interval of zero
or less sends nothing.
Create a heartbeat for the run whose body runs on loop.
Arguments
loop: The run's event loop, probed for lag on each report.interval: Seconds between reports.fields: Run identity carried on every report:task_hash,project_id,datasource_nameandtrigger; other keys are ignored.probe_timeout: How long a loop probe waits for its callback. Defaults to the smaller of half the interval and 30 seconds.clock: Monotonic clock, injectable for tests.
Methods
start
def start(self) ‑> None:Start the heartbeat thread, unless disabled or already started.
stop
def stop(self) ‑> None:Stop the heartbeat thread, without waiting for a probe in flight.