Skip to content

Instantly share code, notes, and snippets.

@mkmik
Created July 16, 2012 09:46
Show Gist options
  • Save mkmik/3121857 to your computer and use it in GitHub Desktop.
Save mkmik/3121857 to your computer and use it in GitHub Desktop.
import stackless
c = stackless.channel()
def receiver(c, name):
while True:
val =c.receive()
print name, val
stackless.schedule()
stackless.tasklet(receiver)(c, 'a')
stackless.tasklet(receiver)(c, 'b')
for i in xrange(0, 10):
c.send(i)
if hasattr(c.queue, '__getitem__'):
# pypy
c.queue[0].kill()
else:
# stackless
c.queue.kill()
c.send(100)
c.send(200)
print "NEVER REACHED ON PYPY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment