summaryrefslogtreecommitdiff
path: root/taskflow/examples
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-11-16 02:44:14 -0800
committerAlexander Gorodnev <agorodnev@griddynamics.com>2013-11-21 18:38:44 +0400
commitdb15db8186f73f7129d6130099dc793bf475f890 (patch)
treec4e1c116a504f65967fbb25b7c2b718506c052c3 /taskflow/examples
parent359ce523f442e3c3c5f762a966e92d44c9b700ab (diff)
downloadtaskflow-db15db8186f73f7129d6130099dc793bf475f890.tar.gz
Fix up python 3.3 incompatabilities
Make the python 3.3 testing work by selectively disabling & including eventlet, switch to testtools and testrepository which has 2.6, 2.7, 3.2+ unified testing support so that we can correctly run our tests in all supported python versions. Closes-Bug: #1251660 Co-authored-by: Alexander Gorodnev <agorodnev@griddynamics.com> Change-Id: I23b6f04387cfd3bf6b5a044edffa446ca897ce3a
Diffstat (limited to 'taskflow/examples')
-rw-r--r--taskflow/examples/resume_vm_boot.py5
-rw-r--r--taskflow/examples/resume_volume_create.py11
-rw-r--r--taskflow/examples/reverting_linear.out.txt2
-rw-r--r--taskflow/examples/reverting_linear.py2
-rw-r--r--taskflow/examples/simple_linear_listening.out.txt4
-rw-r--r--taskflow/examples/simple_linear_listening.py4
6 files changed, 14 insertions, 14 deletions
diff --git a/taskflow/examples/resume_vm_boot.py b/taskflow/examples/resume_vm_boot.py
index ca99f3b..0a16f37 100644
--- a/taskflow/examples/resume_vm_boot.py
+++ b/taskflow/examples/resume_vm_boot.py
@@ -81,7 +81,7 @@ def get_backend():
class PrintText(task.Task):
"""Just inserts some text print outs in a workflow."""
def __init__(self, print_what, no_slow=False):
- content_hash = hashlib.md5(print_what).hexdigest()[0:8]
+ content_hash = hashlib.md5(print_what.encode('utf-8')).hexdigest()[0:8]
super(PrintText, self).__init__(name="Print: %s" % (content_hash))
self._text = print_what
self._no_slow = no_slow
@@ -257,8 +257,9 @@ except (IndexError, ValueError):
# Set up how we want our engine to run, serial, parallel...
engine_conf = {
'engine': 'parallel',
- 'executor': e_utils.GreenExecutor(5),
}
+if e_utils.EVENTLET_AVAILABLE:
+ engine_conf['executor'] = e_utils.GreenExecutor(5)
# Create/fetch a logbook that will track the workflows work.
book = None
diff --git a/taskflow/examples/resume_volume_create.py b/taskflow/examples/resume_volume_create.py
index d189b5f..1c35c73 100644
--- a/taskflow/examples/resume_volume_create.py
+++ b/taskflow/examples/resume_volume_create.py
@@ -38,7 +38,6 @@ from taskflow import engines
from taskflow import task
from taskflow.persistence import backends
-from taskflow.utils import eventlet_utils as e_utils
from taskflow.utils import persistence_utils as p_utils
@@ -83,7 +82,7 @@ def get_backend():
class PrintText(task.Task):
def __init__(self, print_what, no_slow=False):
- content_hash = hashlib.md5(print_what).hexdigest()[0:8]
+ content_hash = hashlib.md5(print_what.encode('utf-8')).hexdigest()[0:8]
super(PrintText, self).__init__(name="Print: %s" % (content_hash))
self._text = print_what
self._no_slow = no_slow
@@ -156,13 +155,13 @@ else:
flow_detail = find_flow_detail(backend, book_id, flow_id)
# Annnnd load and run.
+engine_conf = {
+ 'engine': 'serial',
+}
engine = engines.load(flow,
flow_detail=flow_detail,
backend=backend,
- engine_conf={
- 'engine': 'parallel',
- 'executor': e_utils.GreenExecutor(10),
- })
+ engine_conf=engine_conf)
engine.run()
# How to use.
diff --git a/taskflow/examples/reverting_linear.out.txt b/taskflow/examples/reverting_linear.out.txt
index 37c4bd9..9928652 100644
--- a/taskflow/examples/reverting_linear.out.txt
+++ b/taskflow/examples/reverting_linear.out.txt
@@ -2,4 +2,4 @@ Calling jim 555.
Calling joe 444.
Calling 444 and apologizing.
Calling 555 and apologizing.
-Flow failed: IOError('Suzzie not home right now.',)
+Flow failed: Suzzie not home right now.
diff --git a/taskflow/examples/reverting_linear.py b/taskflow/examples/reverting_linear.py
index 1a39561..05ec083 100644
--- a/taskflow/examples/reverting_linear.py
+++ b/taskflow/examples/reverting_linear.py
@@ -98,4 +98,4 @@ except Exception as e:
# You will also note that this is not a problem in this case since no
# parallelism is involved; this is ensured by the usage of a linear flow,
# which runs serially as well as the default engine type which is 'serial'.
- print("Flow failed: %r" % e)
+ print("Flow failed: %s" % e)
diff --git a/taskflow/examples/simple_linear_listening.out.txt b/taskflow/examples/simple_linear_listening.out.txt
index ee51ef4..bf3304a 100644
--- a/taskflow/examples/simple_linear_listening.out.txt
+++ b/taskflow/examples/simple_linear_listening.out.txt
@@ -1,10 +1,10 @@
Flow => RUNNING
Task __main__.call_jim => RUNNING
Calling jim.
-Context = {'joe_number': 444, 'jim_number': 555}
+Context = [('jim_number', 555), ('joe_number', 444)]
Task __main__.call_jim => SUCCESS
Task __main__.call_joe => RUNNING
Calling joe.
-Context = {'joe_number': 444, 'jim_number': 555}
+Context = [('jim_number', 555), ('joe_number', 444)]
Task __main__.call_joe => SUCCESS
Flow => SUCCESS
diff --git a/taskflow/examples/simple_linear_listening.py b/taskflow/examples/simple_linear_listening.py
index dcb35cc..ca38fce 100644
--- a/taskflow/examples/simple_linear_listening.py
+++ b/taskflow/examples/simple_linear_listening.py
@@ -58,12 +58,12 @@ from taskflow import task
def call_jim(context):
print("Calling jim.")
- print("Context = %s" % (context))
+ print("Context = %s" % (sorted(context.items(), key=lambda x: x[0])))
def call_joe(context):
print("Calling joe.")
- print("Context = %s" % (context))
+ print("Context = %s" % (sorted(context.items(), key=lambda x: x[0])))
def flow_watch(state, details):