Use constants for revert automatically provided kwargs
Instead of using strings use module level constants for the automatically provided keyword arguments to the tasks revert function. This makes it easier for users of taskflow to associate these constants with the actual keywords, without having to resort to using raw strings directly. Change-Id: I12726812615052d8405071d46272ef2b8286cfe2
This commit is contained in:
@@ -19,6 +19,7 @@ import abc
|
||||
from concurrent import futures
|
||||
import six
|
||||
|
||||
from taskflow import task as _task
|
||||
from taskflow.utils import async_utils
|
||||
from taskflow.utils import misc
|
||||
from taskflow.utils import threading_utils
|
||||
@@ -44,8 +45,8 @@ def _execute_task(task, arguments, progress_callback):
|
||||
|
||||
def _revert_task(task, arguments, result, failures, progress_callback):
|
||||
kwargs = arguments.copy()
|
||||
kwargs['result'] = result
|
||||
kwargs['flow_failures'] = failures
|
||||
kwargs[_task.REVERT_RESULT] = result
|
||||
kwargs[_task.REVERT_FLOW_FAILURES] = failures
|
||||
with task.autobind('update_progress', progress_callback):
|
||||
try:
|
||||
task.pre_revert()
|
||||
|
||||
@@ -27,6 +27,14 @@ from taskflow.utils import reflection
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
# Constants passed into revert kwargs.
|
||||
#
|
||||
# Contain the execute() result (if any).
|
||||
REVERT_RESULT = 'result'
|
||||
#
|
||||
# The cause of the flow failure/s
|
||||
REVERT_FLOW_FAILURES = 'flow_failures'
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseTask(atom.Atom):
|
||||
|
||||
Reference in New Issue
Block a user