Skip to content

Instantly share code, notes, and snippets.

@ls0f
Last active August 29, 2015 14:26
Show Gist options
  • Save ls0f/2bbbf91a1b45bc1d926e to your computer and use it in GitHub Desktop.
Save ls0f/2bbbf91a1b45bc1d926e to your computer and use it in GitHub Desktop.
python-producer-consumer
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