Skip to content

Instantly share code, notes, and snippets.

@saghul
Created November 29, 2013 13:43
Show Gist options
  • Save saghul/7705879 to your computer and use it in GitHub Desktop.
Save saghul/7705879 to your computer and use it in GitHub Desktop.
import fibers
import threading
def test(*args):
return 42
def run_test():
for i in xrange(1000000):
f = fibers.Fiber(target=test)
r = f.switch()
assert r==42
threads = [threading.Thread(target=run_test) for x in xrange(10)]
[t.start() for t in threads]
[t.join() for t in threads]
import greenlet
import threading
def test(*args):
return 42
def run_test():
for i in xrange(1000000):
f = greenlet.greenlet(test)
r = f.switch()
assert r==42
threads = [threading.Thread(target=run_test) for x in xrange(10)]
[t.start() for t in threads]
[t.join() for t in threads]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment