asyncio_slow: Add coroutine example from docs.

asyncio
Paul Sokolovsky 2014-05-01 23:48:41 +03:00
rodzic b0c4fc7536
commit 93178819b3
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,12 @@
#https://docs.python.org/3.4/library/asyncio-task.html#example-hello-world-coroutine
#import asyncio
import asyncio_slow as asyncio
@asyncio.coroutine
def greet_every_two_seconds():
while True:
print('Hello World')
yield from asyncio.sleep(2)
loop = asyncio.get_event_loop()
loop.run_until_complete(greet_every_two_seconds())