Merge "Use the class defined constant instead of raw strings"
This commit is contained in:
		@@ -7,6 +7,8 @@ Notifications and listeners
 | 
			
		||||
    from taskflow import task
 | 
			
		||||
    from taskflow.patterns import linear_flow
 | 
			
		||||
    from taskflow import engines
 | 
			
		||||
    from taskflow.types import notifier
 | 
			
		||||
    ANY = notifier.Notifier.ANY
 | 
			
		||||
 | 
			
		||||
--------
 | 
			
		||||
Overview
 | 
			
		||||
@@ -57,7 +59,7 @@ A basic example is:
 | 
			
		||||
   >>> flo = linear_flow.Flow("cat-dog").add(
 | 
			
		||||
   ...   CatTalk(), DogTalk(provides="dog"))
 | 
			
		||||
   >>> eng = engines.load(flo, store={'meow': 'meow', 'woof': 'woof'})
 | 
			
		||||
   >>> eng.notifier.register("*", flow_transition)
 | 
			
		||||
   >>> eng.notifier.register(ANY, flow_transition)
 | 
			
		||||
   >>> eng.run()
 | 
			
		||||
   Flow 'cat-dog' transition to state RUNNING
 | 
			
		||||
   meow
 | 
			
		||||
@@ -93,7 +95,7 @@ A basic example is:
 | 
			
		||||
   >>> flo.add(CatTalk(), DogTalk(provides="dog"))
 | 
			
		||||
   <taskflow.patterns.linear_flow.Flow object at 0x...>
 | 
			
		||||
   >>> eng = engines.load(flo, store={'meow': 'meow', 'woof': 'woof'})
 | 
			
		||||
   >>> eng.task_notifier.register("*", task_transition)
 | 
			
		||||
   >>> eng.task_notifier.register(ANY, task_transition)
 | 
			
		||||
   >>> eng.run()
 | 
			
		||||
   Task 'CatTalk' transition to state RUNNING
 | 
			
		||||
   meow
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,9 @@ import taskflow.engines
 | 
			
		||||
from taskflow.patterns import graph_flow as gf
 | 
			
		||||
from taskflow.patterns import linear_flow as lf
 | 
			
		||||
from taskflow import task
 | 
			
		||||
from taskflow.types import notifier
 | 
			
		||||
 | 
			
		||||
ANY = notifier.Notifier.ANY
 | 
			
		||||
 | 
			
		||||
import example_utils as eu  # noqa
 | 
			
		||||
 | 
			
		||||
@@ -160,11 +163,11 @@ spec = {
 | 
			
		||||
 | 
			
		||||
engine = taskflow.engines.load(flow, store={'spec': spec.copy()})
 | 
			
		||||
 | 
			
		||||
# This registers all (*) state transitions to trigger a call to the flow_watch
 | 
			
		||||
# function for flow state transitions, and registers the same all (*) state
 | 
			
		||||
# transitions for task state transitions.
 | 
			
		||||
engine.notifier.register('*', flow_watch)
 | 
			
		||||
engine.task_notifier.register('*', task_watch)
 | 
			
		||||
# This registers all (ANY) state transitions to trigger a call to the
 | 
			
		||||
# flow_watch function for flow state transitions, and registers the
 | 
			
		||||
# same all (ANY) state transitions for task state transitions.
 | 
			
		||||
engine.notifier.register(ANY, flow_watch)
 | 
			
		||||
engine.task_notifier.register(ANY, task_watch)
 | 
			
		||||
 | 
			
		||||
eu.print_wrapped("Building a car")
 | 
			
		||||
engine.run()
 | 
			
		||||
@@ -176,8 +179,8 @@ engine.run()
 | 
			
		||||
spec['doors'] = 5
 | 
			
		||||
 | 
			
		||||
engine = taskflow.engines.load(flow, store={'spec': spec.copy()})
 | 
			
		||||
engine.notifier.register('*', flow_watch)
 | 
			
		||||
engine.task_notifier.register('*', task_watch)
 | 
			
		||||
engine.notifier.register(ANY, flow_watch)
 | 
			
		||||
engine.task_notifier.register(ANY, task_watch)
 | 
			
		||||
 | 
			
		||||
eu.print_wrapped("Building a wrong car that doesn't match specification")
 | 
			
		||||
try:
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,9 @@ sys.path.insert(0, top_dir)
 | 
			
		||||
import taskflow.engines
 | 
			
		||||
from taskflow.patterns import linear_flow as lf
 | 
			
		||||
from taskflow import task
 | 
			
		||||
from taskflow.types import notifier
 | 
			
		||||
 | 
			
		||||
ANY = notifier.Notifier.ANY
 | 
			
		||||
 | 
			
		||||
# INTRO: In this example we create two tasks (this time as functions instead
 | 
			
		||||
# of task subclasses as in the simple_linear.py example), each of which ~calls~
 | 
			
		||||
@@ -92,8 +95,8 @@ engine = taskflow.engines.load(flow, store={
 | 
			
		||||
# notification objects that a engine exposes. The usage of a '*' (kleene star)
 | 
			
		||||
# here means that we want to be notified on all state changes, if you want to
 | 
			
		||||
# restrict to a specific state change, just register that instead.
 | 
			
		||||
engine.notifier.register('*', flow_watch)
 | 
			
		||||
engine.task_notifier.register('*', task_watch)
 | 
			
		||||
engine.notifier.register(ANY, flow_watch)
 | 
			
		||||
engine.task_notifier.register(ANY, task_watch)
 | 
			
		||||
 | 
			
		||||
# And now run!
 | 
			
		||||
engine.run()
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,8 @@ from taskflow import task
 | 
			
		||||
from taskflow.types import notifier
 | 
			
		||||
from taskflow.utils import threading_utils
 | 
			
		||||
 | 
			
		||||
ANY = notifier.Notifier.ANY
 | 
			
		||||
 | 
			
		||||
# INTRO: This examples shows how to use a remote workers event notification
 | 
			
		||||
# attribute to proxy back task event notifications to the controlling process.
 | 
			
		||||
#
 | 
			
		||||
@@ -94,7 +96,7 @@ WORKER_CONF = {
 | 
			
		||||
 | 
			
		||||
def run(engine_options):
 | 
			
		||||
    reporter = EventReporter()
 | 
			
		||||
    reporter.notifier.register(notifier.Notifier.ANY, event_receiver)
 | 
			
		||||
    reporter.notifier.register(ANY, event_receiver)
 | 
			
		||||
    flow = lf.Flow('event-reporter').add(reporter)
 | 
			
		||||
    eng = engines.load(flow, engine='worker-based', **engine_options)
 | 
			
		||||
    eng.run()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user