Esempio n. 1
0
 def test_pipelines_can_be_executed_in_processes(self):
     p_queue = multiprocessing.Queue()
     count.connect(increment)
     increment.connect(save_to(p_queue))
     p_pype = ProcessPipelineFactory()
     p_pype.run_pipeline(count)
     result = []
     while len(result) < count.until:
         result.append(p_queue.get())
     self.assertEqual(result, ONE_TO_TEN)
Esempio n. 2
0

@pipeline_node
def count():
    for i in range(50):
        yield i


@pipeline_node
def increment(i):
    return i + 1


increment2 = PipelineNode(increment)


@pipeline_node
def log(i):
    print(i)


count.connect(increment, increment2)
increment.connect(log)
increment2.connect(log)

t_pype = ThreadPipelineFactory()
t_pype.run_pipeline(count)

p_pype = ProcessPipelineFactory()
p_pype.run_pipeline(count)