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:
Joshua Harlow
2014-10-16 17:35:19 -07:00
parent 453323900b
commit a15e07a0a1
2 changed files with 11 additions and 2 deletions

View File

@@ -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()

View File

@@ -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):