Skip to content

Commit 9317881

Browse files
committed
asyncio_slow: Add coroutine example from docs.
1 parent b0c4fc7 commit 9317881

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

asyncio_slow/test_hello_world.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#https://docs.python.org/3.4/library/asyncio-task.html#example-hello-world-coroutine
2+
#import asyncio
3+
import asyncio_slow as asyncio
4+
5+
@asyncio.coroutine
6+
def greet_every_two_seconds():
7+
while True:
8+
print('Hello World')
9+
yield from asyncio.sleep(2)
10+
11+
loop = asyncio.get_event_loop()
12+
loop.run_until_complete(greet_every_two_seconds())

0 commit comments

Comments
 (0)