Created
January 27, 2011 03:46
-
-
Save igorsobreira/798030 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 greenlet import greenlet | |
from time import sleep | |
def ping(): | |
while True: | |
print "ping" | |
sleep(0.5) | |
pong_greenlet.switch() | |
def pong(): | |
while True: | |
print "pong" | |
sleep(0.5) | |
ping_greenlet.switch() | |
ping_greenlet = greenlet(ping) | |
pong_greenlet = greenlet(pong) | |
ping_greenlet.switch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment