Created
December 11, 2011 21:47
-
-
Save cwvh/1462946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pipeline import pipeline | |
@pipeline() | |
def foo(): | |
pass | |
@pipeline() | |
def baz(): | |
pass | |
print "Okay, here we go!" | |
pipeline.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
__all__ = ['pipeline'] | |
pipelines = {} | |
class pipeline(object): | |
def __init__(self, in_ports, out_port, ip='localhost'): | |
... | |
def __call__(self, fn): | |
if self.inputs: | |
def pipeline(): | |
ready = dict(self.poller.poll()) | |
for input in self.inputs: | |
if ready.get(input) == zmq.POLLIN: | |
if self.output: | |
self.output.send(fn(input.recv())) | |
else: | |
fn(input.recv()) | |
elif self.output: | |
def pipeline(): | |
self.output.send(fn()) | |
else: | |
pipeline = fn | |
pipelines[fn.__name__] = pipeline | |
@staticmethod | |
def run(): | |
for name, function in pipelines.iteritems(): | |
print 'forking', name, 'and running!' | |
#forkexec function() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment