From 4dad6fefd530f70ddac99ec12c5b27ec3f443750 Mon Sep 17 00:00:00 2001 From: Changbin Liu Date: Fri, 3 Jan 2014 22:27:52 -0500 Subject: [PATCH] Misc minor fixes to taskflow/examples Change-Id: Iecf7693239d93e5a43cf5470bcfcdec605410ce4 --- taskflow/examples/persistence_example.py | 15 +++++++-------- taskflow/examples/resume_from_backend.py | 7 ++++--- taskflow/examples/reverting_linear.py | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/taskflow/examples/persistence_example.py b/taskflow/examples/persistence_example.py index 5e956bd3..54b84244 100644 --- a/taskflow/examples/persistence_example.py +++ b/taskflow/examples/persistence_example.py @@ -20,6 +20,7 @@ import contextlib import logging import os import sys +import tempfile import traceback logging.basicConfig(level=logging.ERROR) @@ -36,8 +37,6 @@ from taskflow.persistence import logbook from taskflow import task from taskflow.utils import persistence_utils as p_utils -import tempfile - # INTRO: In this example we create two tasks, one that will say hi and one # that will say bye with optional capability to raise an error while @@ -61,7 +60,7 @@ class HiTask(task.Task): print("Hi!") def revert(self, **kwargs): - print("Whooops, said hi to early, take that back!") + print("Whooops, said hi too early, take that back!") class ByeTask(task.Task): @@ -77,9 +76,9 @@ class ByeTask(task.Task): # This generates your flow structure (at this stage nothing is ran). def make_flow(blowup=False): - flo = lf.Flow("hello-world") - flo.add(HiTask(), ByeTask(blowup)) - return flo + flow = lf.Flow("hello-world") + flow.add(HiTask(), ByeTask(blowup)) + return flow # Persist the flow and task state here, if the file exists already blowup @@ -109,11 +108,11 @@ engine_config = { # Make a flow that will blowup if the file doesn't exist previously, if it # did exist, assume we won't blowup (and therefore this shows the undo # and redo that a flow will go through). -flo = make_flow(blowup=blowup) +flow = make_flow(blowup=blowup) print_wrapped("Running") try: - eng = engines.load(flo, **engine_config) + eng = engines.load(flow, **engine_config) eng.run() try: os.unlink(persist_filename) diff --git a/taskflow/examples/resume_from_backend.py b/taskflow/examples/resume_from_backend.py index 6ee60fb5..5e40a174 100644 --- a/taskflow/examples/resume_from_backend.py +++ b/taskflow/examples/resume_from_backend.py @@ -131,10 +131,11 @@ print_wrapped("Resuming and running again") # example shows how another process may unsuspend a given flow and start it # again for situations where this is useful to-do (say the process running # the above flow crashes). +flow2 = flow_factory() flowdetail2 = find_flow_detail(backend, logbook.uuid, flowdetail.uuid) -engine2 = taskflow.engines.load(flow_factory(), - flow_detail=flowdetail, +engine2 = taskflow.engines.load(flow2, + flow_detail=flowdetail2, backend=backend) engine2.run() -print_task_states(flowdetail, "At the end") +print_task_states(flowdetail2, "At the end") diff --git a/taskflow/examples/reverting_linear.py b/taskflow/examples/reverting_linear.py index 05ec083f..3948ecfc 100644 --- a/taskflow/examples/reverting_linear.py +++ b/taskflow/examples/reverting_linear.py @@ -39,7 +39,7 @@ from taskflow import task # phone ~calls~. # # This simulated calling makes it appear like all three calls occur or all -# three don't occur (transactional like capabilities). No persistence layer is +# three don't occur (transaction-like capabilities). No persistence layer is # used here so reverting and executing will not handle process failure. # # This example shows a basic usage of the taskflow structures without involving