The heat.engine.scheduler ModuleΒΆ

class heat.engine.scheduler.DependencyTaskGroup(dependencies, task=<function <lambda> at 0x7fdc8099bd70>, reverse=False, name=None, error_wait_time=None, aggregate_exceptions=False)[source]

Bases: object

A task which manages a group of subtasks that have ordering dependencies.

cancel_all(grace_period=None)[source]
exception heat.engine.scheduler.ExceptionGroup(exceptions=None)[source]

Bases: exceptions.Exception

Container for multiple exceptions.

This exception is used by DependencyTaskGroup when the flag aggregate_exceptions is set to True and it’s re-raised again when all tasks are finished. This way it can be caught later on so that the individual exceptions can be acted upon.

class heat.engine.scheduler.PollingTaskGroup(tasks, name=None)[source]

Bases: object

A task which manages a group of subtasks.

When the task is started, all of its subtasks are also started. The task completes when all subtasks are complete.

Once started, the subtasks are assumed to be only polling for completion of an asynchronous operation, so no attempt is made to give them equal scheduling slots.

classmethod from_task_with_args(task, *arg_lists, **kwarg_lists)[source]

Return a new PollingTaskGroup where each subtask is identical except for the arguments passed to it.

Each argument to use should be passed as a list (or iterable) of values such that one is passed in the corresponding position for each subtask. The number of subtasks spawned depends on the length of the argument lists. For example:

PollingTaskGroup.from_task_with_args(my_task,
                                     [1, 2, 3],
                                     alpha=['a', 'b', 'c'])

will start three TaskRunners that will run:

my_task(1, alpha='a')
my_task(2, alpha='b')
my_task(3, alpha='c')

respectively.

If multiple arguments are supplied, each list should be of the same length. In the case of any discrepancy, the length of the shortest argument list will be used, and any extra arguments discarded.

class heat.engine.scheduler.TaskRunner(task, *args, **kwargs)[source]

Bases: object

Wrapper for a resumable task (co-routine).

cancel(grace_period=None)[source]

Cancel the task and mark it as done.

done()[source]

Return True if the task is complete.

run_to_completion(wait_time=1)[source]

Run the task to completion.

The task will sleep for wait_time seconds between steps. To avoid sleeping, pass None for wait_time.

start(timeout=None)[source]

Initialise the task and run its first step.

If a timeout is specified, any attempt to step the task after that number of seconds has elapsed will result in a Timeout being raised inside the task.

started()[source]

Return True if the task has been started.

step()[source]

Run another step of the task, and return True if the task is complete; False otherwise.

exception heat.engine.scheduler.TimedCancel(task_runner, timeout)[source]

Bases: heat.engine.scheduler.Timeout

trigger(generator)[source]

Trigger the timeout on a given generator.

exception heat.engine.scheduler.Timeout(task_runner, timeout)[source]

Bases: exceptions.BaseException

Timeout exception, raised within a task when it has exceeded its allotted (wallclock) running time.

This allows the task to perform any necessary cleanup, as well as use a different exception to notify the controlling task if appropriate. If the task suppresses the exception altogether, it will be cancelled but the controlling task will not be notified of the timeout.

expired()[source]
trigger(generator)[source]

Trigger the timeout on a given generator.

heat.engine.scheduler.task_description(task)[source]

Return a human-readable string description of a task suitable for logging the status of the task.

heat.engine.scheduler.wrappertask(task)[source]

Decorator for a task that needs to drive a subtask.

This is essentially a replacement for the Python 3-only “yield from” keyword (PEP 380), using the “yield” keyword that is supported in Python 2. For example:

@wrappertask
def parent_task(self):
    self.setup()

    yield self.child_task()

    self.cleanup()

Previous topic

The heat.engine Module

Next topic

The heat.engine.lifecycle_plugin Module

This Page