stream_task_process_tree#

MonitorApi.stream_task_process_tree(task_id, *, backlog=100, max_messages=None)#

Stream process tree metric updates for a specific task.

Subscribes to process-tree metric messages and yields each snapshot as the server pushes it. The server typically pushes a new snapshot on a fixed interval while the task is running, allowing you to observe process lifecycle in real time.

Return type:

Generator[MonitorMessage, None, None]

Parameters:
task_idstr

The task identifier to monitor.

backlogint, optional

Number of historical snapshots to request on connect. The default is 100.

max_messagesint or None, optional

Maximum total snapshots to yield before closing the connection. The default is None, which streams indefinitely until interrupted or the server closes the connection.

Yields:
MonitorMessage

Parsed JSON process-tree snapshot dicts from the server.

Examples

>>> for snapshot in api.stream_task_process_tree("task-123"):
...     pids = [p["pid"] for p in snapshot.get("processes", [])]
...     print(f"Running PIDs: {pids}")