Created
January 20, 2014 07:46
-
-
Save sgrankin/8516452 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
from gevent import spawn | |
from gevent.queue import Queue | |
def whisper(left, right): | |
left.put(right.get() + 1) | |
def main(): | |
n = 100000 | |
leftmost = Queue() | |
left, right = None, leftmost | |
for _ in range(n): | |
left, right = right, Queue() | |
spawn(whisper, left, right) | |
right.put(1) | |
print leftmost.get() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment