Created
November 29, 2013 13:43
-
-
Save saghul/7705879 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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] | |
This file contains hidden or 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 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