CompoundTask Class
A Task of Tasks.
Contains shared logic that drives all of its sub-classes. Should never be instantiated on its own.
Instantiate CompoundTask attributes.
Constructor
CompoundTask(tasks: List[TaskBase], compound_action_constructor=None)
Parameters
| Name | Description |
|---|---|
|
tasks
Required
|
<xref:List>[<xref:Task>]
The children/sub-tasks of this Task |
|
compound_action_constructor
|
Either None or, a WhenAllAction or WhenAnyAction constructor. It is None when using the V1 replay protocol, where no Compound Action objects size and compound actions are represented as arrays of actions. It is not None when using the V2 replay protocol. Default value: None
|
Methods
| change_state |
Transition a running Task to a terminal state: success or failure. |
| handle_completion |
Manage sub-task completion events. |
| propagate |
Notify parent Task of this Task's state change. |
| set_is_played |
Set the is_played flag for the Task. Needed for updating the orchestrator's is_replaying flag. |
| set_value |
Set the value of this Task: either an exception of a result. |
| try_set_value |
Transition a CompoundTask to a terminal state and set its value. Should be implemented by sub-classes. |
change_state
handle_completion
propagate
Notify parent Task of this Task's state change.
propagate()
set_is_played
Set the is_played flag for the Task.
Needed for updating the orchestrator's is_replaying flag.
set_is_played(is_played: bool)
Parameters
| Name | Description |
|---|---|
|
is_played
Required
|
Whether the latest event for this Task has been played before. |
set_value
Set the value of this Task: either an exception of a result.
set_value(is_error: bool, value: Any)
Parameters
| Name | Description |
|---|---|
|
is_error
Required
|
Whether the value represents an exception of a result. |
|
value
Required
|
The value of this Task |
Exceptions
| Type | Description |
|---|---|
|
When the Task failed but its value was not an Exception |
try_set_value
Transition a CompoundTask to a terminal state and set its value.
Should be implemented by sub-classes.
try_set_value(child: TaskBase)
Parameters
| Name | Description |
|---|---|
|
child
Required
|
A sub-task that just completed |
Exceptions
| Type | Description |
|---|---|
|
This method needs to be implemented by each subclass. |
Attributes
is_completed
Get indicator of whether the task completed.
Note that completion is not equivalent to success.