summaryrefslogtreecommitdiff
path: root/taskflow/engines/action_engine/executor.py
diff options
context:
space:
mode:
authorGreg Hill <greg.hill@rackspace.com>2014-08-06 08:40:42 -0500
committerGreg Hill <greg.hill@rackspace.com>2014-08-06 08:40:42 -0500
commita84b3240fcabd030b2c970eed46aa9f20cf0afd2 (patch)
tree13874f831f4b4d74b6a125beefe68570b7064141 /taskflow/engines/action_engine/executor.py
parenta68d40bf02a69957ad4cd2e4eb0646e2b9c74575 (diff)
downloadtaskflow-a84b3240fcabd030b2c970eed46aa9f20cf0afd2.tar.gz
add pre/post execute/retry callbacks to tasks
This enables us to execute code to set up or tear down global state in running tasks. Change-Id: Ib1e5d03ab46b3ce1d03fa83b91bf437fa950b758 Implements: blueprint task-callbacks
Diffstat (limited to 'taskflow/engines/action_engine/executor.py')
-rw-r--r--taskflow/engines/action_engine/executor.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/taskflow/engines/action_engine/executor.py b/taskflow/engines/action_engine/executor.py
index 816060f..e28e863 100644
--- a/taskflow/engines/action_engine/executor.py
+++ b/taskflow/engines/action_engine/executor.py
@@ -31,11 +31,14 @@ REVERTED = 'reverted'
def _execute_task(task, arguments, progress_callback):
with task.autobind('update_progress', progress_callback):
try:
+ task.pre_execute()
result = task.execute(**arguments)
except Exception:
# NOTE(imelnikov): wrap current exception with Failure
# object and return it.
result = misc.Failure()
+ finally:
+ task.post_execute()
return (task, EXECUTED, result)
@@ -45,11 +48,14 @@ def _revert_task(task, arguments, result, failures, progress_callback):
kwargs['flow_failures'] = failures
with task.autobind('update_progress', progress_callback):
try:
+ task.pre_revert()
result = task.revert(**kwargs)
except Exception:
# NOTE(imelnikov): wrap current exception with Failure
# object and return it.
result = misc.Failure()
+ finally:
+ task.post_revert()
return (task, REVERTED, result)