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:
- Parameters:
- task_id
str The task identifier to monitor.
- backlog
int,optional Number of historical snapshots to request on connect. The default is
100.- max_messages
intorNone,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.
- task_id
- Yields:
MonitorMessageParsed 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}")