Last active
December 12, 2015 10:19
-
-
Save saghul/4758151 to your computer and use it in GitHub Desktop.
This file contains 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
$ python t.py | |
ping | |
ping | |
ping | |
ping | |
pingping | |
stop1 | |
Task(<_foo>)<PENDING, [<function _raise_stop_error at 0x1010ef440>]>False | |
ping | |
pingping | |
ping | |
stop2 | |
Task(<_foo>)<result=None> | |
True |
This file contains 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 rose | |
from tulip import events | |
from tulip import tasks | |
#events.set_event_loop_policy(rose.EventLoopPolicy()) | |
reactor = events.get_event_loop() | |
def _foo(): | |
x = 0 | |
while x < 10: | |
print("ping") | |
yield from (tasks.sleep(0.1)) | |
x += 1 | |
if x == 5: | |
reactor.stop() | |
t = tasks.Task(_foo()) | |
reactor.run_until_complete(t) | |
print("stop1") | |
print(t) | |
print(t.done()) | |
reactor.run_until_complete(t) | |
print("stop2") | |
print(t) | |
print(t.done()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment