Task

class dias.Task(task_name, task_config, write_dir, state_dir)

Bases: object

dias Task.

The Task class is used by the scheduler to hold a task’s instantiated analyzer along with associated bookkeeping data

Hint

Tasks support rich comparison and ordering. When comparing tasks, the task with the earlier start_time is sorted first. If two tasks have the same start_time, they are sorted lexicographically by name.

Methods

cleanup(self, dir, max_size[, check]) Delete old files in case of disk space overage and inform analyzer.
increment(self) Increment start_time by period.
prepare(self, reference_time[, …]) Prepare a task for execution.
runner(self) Execute run method of the task.
running(self) Tell if the task is running.

Methods Summary

cleanup(self, dir, max_size[, check]) Delete old files in case of disk space overage and inform analyzer.
increment(self) Increment start_time by period.
prepare(self, reference_time[, …]) Prepare a task for execution.
runner(self) Execute run method of the task.
running(self) Tell if the task is running.

Methods Documentation

cleanup(self, dir, max_size, check=False)

Delete old files in case of disk space overage and inform analyzer.

Parameters:
  • dir (str) – Directory to clean up.
  • max_size (float) – Maximum disk space allowed in directory.
  • check (bool) – If True, no files are deleted. Default: False.
Returns:

tuple(int, int) – Total data size before and after cleanup in bytes.

increment(self)

Increment start_time by period.

prepare(self, reference_time, log_level_override=None, start_now=False)

Prepare a task for execution.

Parameters:
  • reference_time (int) – POSIX timestamp indicating when task should be executed, depending on start_now.
  • log_level_override (str or None) – This is the log level specified on the dias command line when the scheduler was started, or None if it wasn’t specified. It will override any log level specified in either the global task config or per-task config files.
  • start_now (bool) – If the task defines start_time, this is ignored. Otherwise, if this is True, the task will be first scheduled for execution as soon as the Scheduler starts up. If this is False, the task will be first scheduled after a random amount of time up to the task’s period.
runner(self)

Execute run method of the task.

This serves as the entry point for a running task. It executes in a worker thread.

Returns:The result of the task.
running(self)

Tell if the task is running.

Returns:boolTrue if the task is running, False otherwise.