ska_sdp_batchlet.utils.monitor.handler module

class ska_sdp_batchlet.utils.monitor.handler.MonitorHandler(stack, generate_reports_on_failure=True, resources=None, logs=None)[source]

Bases: object

Handles all monitoring related operations.

It is responsible for instantiating and starting both LogMonitor and ResourceMonitor instances.

Parameters:
  • stack (ExitStack) -- The ExitStack to register the monitors with. NOTE: The "stack" is pass by reference, and MonitorHandler will modify it.

  • generate_reports_on_failure (bool, default=True) -- Whether to generate monitoring report, even if there are any failures.

  • resources (dict[dict], optional) -- Optional dictionary of {start: {}, stop: {}} to pass to ResourceMonitor

  • logs (dict, optional) -- Optional dictionary of keyword arguments to pass to LogMonitor

property log_stream

If log monitor is configured, start a new watcher subprocess, and return a io stream on which the logs of a application to be watched can be passed.

If log monitor is not configured, return a nullcontext.