Skip to content

Instantly share code, notes, and snippets.

@djoreilly
Last active December 15, 2015 05:59
Show Gist options
  • Save djoreilly/5212969 to your computer and use it in GitHub Desktop.
Save djoreilly/5212969 to your computer and use it in GitHub Desktop.
$ python co-op.py <br /> func2 <br /> func1
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