diff options
| author | Joshua Harlow <harlowja@gmail.com> | 2015-01-11 00:15:09 -0800 |
|---|---|---|
| committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-01-16 11:51:04 -0800 |
| commit | d92c226fe2d4a4fc402b96354da29dcc22a25574 (patch) | |
| tree | 9a3ef9bcb686784dfda8bb1e1fb8c95ef8169b46 /taskflow/examples | |
| parent | 320955672dafe531533971f4a77fcdae5a7f5a8c (diff) | |
| download | taskflow-d92c226fe2d4a4fc402b96354da29dcc22a25574.tar.gz | |
Add back a 'eventlet_utils' helper utility module
Recreate a very simple eventlet utility module that
has only a few features; one function checks if eventlet is
available and if not raise an exception; and a constant that
can be used by calling code (such as tests or other optional
functionality) to check if eventlet is useable before
proceeding.
Change-Id: I32df0702eeae7c7c78972c9796156dd824b2f123
Diffstat (limited to 'taskflow/examples')
| -rw-r--r-- | taskflow/examples/hello_world.py | 9 | ||||
| -rw-r--r-- | taskflow/examples/parallel_table_multiply.py | 4 | ||||
| -rw-r--r-- | taskflow/examples/resume_vm_boot.py | 4 |
3 files changed, 6 insertions, 11 deletions
diff --git a/taskflow/examples/hello_world.py b/taskflow/examples/hello_world.py index 22f6a3b..f8e0bb2 100644 --- a/taskflow/examples/hello_world.py +++ b/taskflow/examples/hello_world.py @@ -25,17 +25,12 @@ top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) sys.path.insert(0, top_dir) -try: - import eventlet # noqa - EVENTLET_AVAILABLE = True -except ImportError: - EVENTLET_AVAILABLE = False - 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 # INTRO: This is the defacto hello world equivalent for taskflow; it shows how @@ -86,7 +81,7 @@ song.add(PrinterTask("conductor@begin", show_name=False, inject={'output': "*dong*"})) # Run in parallel using eventlet green threads... -if EVENTLET_AVAILABLE: +if eventlet_utils.EVENTLET_AVAILABLE: with futures.GreenThreadPoolExecutor() 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 88562a2..f4550c2 100644 --- a/taskflow/examples/parallel_table_multiply.py +++ b/taskflow/examples/parallel_table_multiply.py @@ -33,7 +33,7 @@ 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 async_utils +from taskflow.utils import eventlet_utils # INTRO: This example walks through a miniature workflow which does a parallel # table modification where each row in the table gets adjusted by a thread, or @@ -97,7 +97,7 @@ def main(): f = make_flow(tbl) # Now run it (using the specified executor)... - if async_utils.EVENTLET_AVAILABLE: + if eventlet_utils.EVENTLET_AVAILABLE: executor = futures.GreenThreadPoolExecutor(max_workers=5) else: executor = futures.ThreadPoolExecutor(max_workers=5) diff --git a/taskflow/examples/resume_vm_boot.py b/taskflow/examples/resume_vm_boot.py index f400d0d..7d34a95 100644 --- a/taskflow/examples/resume_vm_boot.py +++ b/taskflow/examples/resume_vm_boot.py @@ -39,7 +39,7 @@ 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 async_utils +from taskflow.utils import eventlet_utils from taskflow.utils import persistence_utils as p_utils import example_utils as eu # noqa @@ -238,7 +238,7 @@ with eu.get_backend() as backend: # Set up how we want our engine to run, serial, parallel... executor = None - if async_utils.EVENTLET_AVAILABLE: + if eventlet_utils.EVENTLET_AVAILABLE: executor = futures.GreenThreadPoolExecutor(5) # Create/fetch a logbook that will track the workflows work. |
