Skip to content

Instantly share code, notes, and snippets.

@saghul

saghul/output

Last active Dec 12, 2015
Embed
What would you like to do?
$ 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
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