Last active
August 29, 2015 14:26
-
-
Save ls0f/2bbbf91a1b45bc1d926e to your computer and use it in GitHub Desktop.
python-producer-consumer
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 sys | |
def producer(): | |
while True: | |
line = sys.stdin.readline() | |
yield line | |
def consumer(p): | |
line = p.next() | |
while True: | |
print "INPUT:",line, | |
line = p.send('') | |
p = producer() | |
consumer(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment