summaryrefslogtreecommitdiff
path: root/taskflow/examples
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-06-26 14:42:18 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-07-09 15:01:35 -0700
commit27272a2aa70b56182b67a06d3707430e86a0ccde (patch)
tree81368600382a72a411327f08066010aac7ef7509 /taskflow/examples
parent87c12603eb2455802c9baa53caa31fb12e11279e (diff)
downloadtaskflow-27272a2aa70b56182b67a06d3707430e86a0ccde.tar.gz
Integrate futurist (and **remove** taskflow originating code)
Change-Id: If89baa042695f19e42b6368034f3ccf22c2cf0aa
Diffstat (limited to 'taskflow/examples')
-rw-r--r--taskflow/examples/hello_world.py9
-rw-r--r--taskflow/examples/parallel_table_multiply.py6
-rw-r--r--taskflow/examples/resume_vm_boot.py4
-rw-r--r--taskflow/examples/share_engine_thread.py4
4 files changed, 12 insertions, 11 deletions
diff --git a/taskflow/examples/hello_world.py b/taskflow/examples/hello_world.py
index caba527..38a6b38 100644
--- a/taskflow/examples/hello_world.py
+++ b/taskflow/examples/hello_world.py
@@ -25,11 +25,12 @@ top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir))
sys.path.insert(0, top_dir)
+import futurist
+
from taskflow import engines
from taskflow.patterns import linear_flow as lf
from taskflow.patterns import unordered_flow as uf
from taskflow import task
-from taskflow.types import futures
from taskflow.utils import eventlet_utils
@@ -82,19 +83,19 @@ song.add(PrinterTask("conductor@begin",
# Run in parallel using eventlet green threads...
if eventlet_utils.EVENTLET_AVAILABLE:
- with futures.GreenThreadPoolExecutor() as executor:
+ with futurist.GreenThreadPoolExecutor() as executor:
e = engines.load(song, executor=executor, engine='parallel')
e.run()
# Run in parallel using real threads...
-with futures.ThreadPoolExecutor(max_workers=1) as executor:
+with futurist.ThreadPoolExecutor(max_workers=1) as executor:
e = engines.load(song, executor=executor, engine='parallel')
e.run()
# Run in parallel using external processes...
-with futures.ProcessPoolExecutor(max_workers=1) as executor:
+with futurist.ProcessPoolExecutor(max_workers=1) as executor:
e = engines.load(song, executor=executor, engine='parallel')
e.run()
diff --git a/taskflow/examples/parallel_table_multiply.py b/taskflow/examples/parallel_table_multiply.py
index f4550c2..e06e36d 100644
--- a/taskflow/examples/parallel_table_multiply.py
+++ b/taskflow/examples/parallel_table_multiply.py
@@ -27,12 +27,12 @@ top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir))
sys.path.insert(0, top_dir)
+import futurist
from six.moves import range as compat_range
from taskflow import engines
from taskflow.patterns import unordered_flow as uf
from taskflow import task
-from taskflow.types import futures
from taskflow.utils import eventlet_utils
# INTRO: This example walks through a miniature workflow which does a parallel
@@ -98,9 +98,9 @@ def main():
# Now run it (using the specified executor)...
if eventlet_utils.EVENTLET_AVAILABLE:
- executor = futures.GreenThreadPoolExecutor(max_workers=5)
+ executor = futurist.GreenThreadPoolExecutor(max_workers=5)
else:
- executor = futures.ThreadPoolExecutor(max_workers=5)
+ executor = futurist.ThreadPoolExecutor(max_workers=5)
try:
e = engines.load(f, engine='parallel', executor=executor)
for st in e.run_iter():
diff --git a/taskflow/examples/resume_vm_boot.py b/taskflow/examples/resume_vm_boot.py
index 8c7d4ae..ec2293b 100644
--- a/taskflow/examples/resume_vm_boot.py
+++ b/taskflow/examples/resume_vm_boot.py
@@ -31,6 +31,7 @@ top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
sys.path.insert(0, top_dir)
sys.path.insert(0, self_dir)
+import futurist
from oslo_utils import uuidutils
from taskflow import engines
@@ -38,7 +39,6 @@ from taskflow import exceptions as exc
from taskflow.patterns import graph_flow as gf
from taskflow.patterns import linear_flow as lf
from taskflow import task
-from taskflow.types import futures
from taskflow.utils import eventlet_utils
from taskflow.utils import persistence_utils as p_utils
@@ -239,7 +239,7 @@ with eu.get_backend() as backend:
# Set up how we want our engine to run, serial, parallel...
executor = None
if eventlet_utils.EVENTLET_AVAILABLE:
- executor = futures.GreenThreadPoolExecutor(5)
+ executor = futurist.GreenThreadPoolExecutor(5)
# Create/fetch a logbook that will track the workflows work.
book = None
diff --git a/taskflow/examples/share_engine_thread.py b/taskflow/examples/share_engine_thread.py
index 5654fa0..5223721 100644
--- a/taskflow/examples/share_engine_thread.py
+++ b/taskflow/examples/share_engine_thread.py
@@ -27,12 +27,12 @@ top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir))
sys.path.insert(0, top_dir)
+import futurist
import six
from taskflow import engines
from taskflow.patterns import unordered_flow as uf
from taskflow import task
-from taskflow.types import futures
from taskflow.utils import threading_utils as tu
# INTRO: in this example we create 2 dummy flow(s) with a 2 dummy task(s), and
@@ -61,7 +61,7 @@ f2.add(DelayedTask("f2-1"))
f2.add(DelayedTask("f2-2"))
# Run them all using the same futures (thread-pool based) executor...
-with futures.ThreadPoolExecutor() as ex:
+with futurist.ThreadPoolExecutor() as ex:
e1 = engines.load(f1, engine='parallel', executor=ex)
e2 = engines.load(f2, engine='parallel', executor=ex)
iters = [e1.run_iter(), e2.run_iter()]