stream_task_host_resources#

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

Stream CPU and memory metric updates for the host running a specific task.

Resolves the task’s assigned evaluator (via JMS and RMS) and subscribes to host_resources metric messages for that evaluator. Yields each update as it arrives.

Return type:

Generator[MonitorMessage, None, None]

Parameters:
task_idstr

The task identifier to monitor.

project_idstr

The JMS project identifier that owns task_id.

backlogint, optional

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

max_messagesint or None, optional

Maximum total messages 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 host-resource metric dicts from the server.

Examples

>>> for update in api.stream_task_host_resources("task-123", "project-abc"):
...     cpu = update.get("cpu_percent")
...     mem = update.get("memory_percent")
...     print(f"CPU: {cpu}%  Memory: {mem}%")