Misc minor fixes to taskflow/examples

Change-Id: Iecf7693239d93e5a43cf5470bcfcdec605410ce4
This commit is contained in:
Changbin Liu
2014-01-03 22:27:52 -05:00
parent 5352debceb
commit 4dad6fefd5
3 changed files with 12 additions and 12 deletions

View File

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

View File

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

View File

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