Created
November 25, 2012 13:21
-
-
Save Drvanon/4143459 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 time import sleep | |
def foo(): | |
print('foo') | |
def bas(): | |
sleep(1) | |
print('bas') | |
def start(): | |
gr = greenlet.greenlet(foo) | |
# something magical | |
sleep(2) | |
gr.switch() | |
start() | |
bas() | |
start() | |
bas() | |
bas() | |
bas() | |
bas() | |
bas() | |
bas() | |
bas() | |
bas() | |
bas() | |
should result in: | |
bas | |
foo | |
bas | |
bas | |
foo | |
bas | |
bas | |
foo | |
bas | |
bas | |
foo | |
bas | |
bas | |
foo | |
bas | |
foo | |
foo | |
foo | |
^C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment