Last active
December 15, 2015 05:59
-
-
Save djoreilly/5212969 to your computer and use it in GitHub Desktop.
$ python co-op.py <br />
func2 <br />
func1
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 eventlet | |
def func1(): | |
# suspend me and run something else | |
# but switch back to me after 2 seconds (if you can) | |
eventlet.sleep(2) | |
print "func1" | |
def func2(): | |
eventlet.sleep(1) | |
print "func2" | |
f1 = eventlet.spawn(func1) | |
f2 = eventlet.spawn(func2) | |
f1.wait() | |
f2.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment