-
-
Save konradkonrad/ff917da6f81bbc9f658c04bc40664f41 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 itertools import count | |
import gevent | |
from gevent.event import AsyncResult | |
def wait_twice(async_result): | |
print('wait_twice enter') | |
gevent.joinall(set([async_result, async_result]), raise_error=True) | |
print('wait_twice exit') | |
def set_result(async_result): | |
print('set_result enter') | |
async_result.set(1) | |
print('set_result exit') | |
def go_for_ever(): | |
print('go_for_ever enter') | |
for i in count(): | |
print(i) | |
gevent.sleep(.1) | |
print('go_for_ever exit') | |
g = gevent.spawn(go_for_ever) | |
result = AsyncResult() | |
gevent.wait([ | |
gevent.spawn(wait_twice, result), | |
gevent.spawn(set_result, result), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment