diff options
| author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-07-06 15:12:25 -0700 |
|---|---|---|
| committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-07-06 15:12:25 -0700 |
| commit | ae9af359783106a1db6a88638e8ce0d332bcb3d8 (patch) | |
| tree | ab9a25536abd51ef7d0f0d0f254b9b170e9fc3c5 /taskflow/patterns | |
| parent | 06833fee4035b4797919f4f9a43c4b5ca270d1f8 (diff) | |
| download | taskflow-ae9af359783106a1db6a88638e8ce0d332bcb3d8.tar.gz | |
Pass runners instead of task objects/uuids.
Runners contain tasks and provide the identifying
characteristics for the tasks, pass these along to
the underlying components instead of tasks.
Change-Id: I795a52d3a218e508c38ea209d757750ae6a936ea
Diffstat (limited to 'taskflow/patterns')
| -rw-r--r-- | taskflow/patterns/linear_flow.py | 12 | ||||
| -rw-r--r-- | taskflow/patterns/resumption/logbook.py | 19 |
2 files changed, 13 insertions, 18 deletions
diff --git a/taskflow/patterns/linear_flow.py b/taskflow/patterns/linear_flow.py index 6ab0838..47c9b18 100644 --- a/taskflow/patterns/linear_flow.py +++ b/taskflow/patterns/linear_flow.py @@ -160,8 +160,7 @@ class Flow(base.Flow): self.task_notifier.notify(states.STARTED, details={ 'context': context, 'flow': self, - 'task': runner.task, - 'task_uuid': runner.uuid, + 'runner': runner, }) if not simulate_run: result = runner(context, *args, **kwargs) @@ -201,20 +200,17 @@ class Flow(base.Flow): self.task_notifier.notify(states.SUCCESS, details={ 'context': context, 'flow': self, - 'result': result, - 'task': runner.task, - 'task_uuid': runner.uuid, + 'runner': runner, }) except Exception as e: + runner.result = e cause = utils.FlowFailure(runner, self, e) with excutils.save_and_reraise_exception(): # Notify any listeners that the task has errored. self.task_notifier.notify(states.FAILURE, details={ 'context': context, 'flow': self, - 'result': e, - 'task': runner.task, - 'task_uuid': runner.uuid, + 'runner': runner, }) self.rollback(context, cause) diff --git a/taskflow/patterns/resumption/logbook.py b/taskflow/patterns/resumption/logbook.py index a77cd66..604522d 100644 --- a/taskflow/patterns/resumption/logbook.py +++ b/taskflow/patterns/resumption/logbook.py @@ -36,24 +36,23 @@ class Resumption(object): def _task_listener(state, details): """Store the result of the task under the given flow in the log book so that it can be retrieved later.""" - task_id = details['task_uuid'] - task = details['task'] + runner = details['runner'] flow = details['flow'] - LOG.debug("Recording %s:%s of %s has finished state %s", - utils.get_task_name(task), task_id, flow, state) + LOG.debug("Recording %s of %s has finished state %s", + runner, flow, state) # TODO(harlowja): switch to using uuids flow_id = flow.name metadata = {} flow_details = self._logbook[flow_id] if state in (states.SUCCESS, states.FAILURE): - metadata['result'] = details['result'] - if task_id not in flow_details: + metadata['result'] = runner.result + if runner.uuid not in flow_details: metadata['states'] = [state] - metadata['version'] = utils.get_task_version(task) - flow_details.add_task(task_id, metadata) + metadata['version'] = runner.version + flow_details.add_task(runner.uuid, metadata) else: - details = flow_details[task_id] - immediate_version = utils.get_task_version(task) + details = flow_details[runner.uuid] + immediate_version = runner.version recorded_version = details.metadata.get('version') if recorded_version is not None: if not utils.is_version_compatible(recorded_version, |
