From 6ded654afe09c43e97d438bbbc4763bcddd77aa7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 1 May 2014 23:50:40 +0300 Subject: [PATCH] asyncio_slow: Add example for scheduling coro using Task. --- asyncio_slow/test_hello_world_bare.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 asyncio_slow/test_hello_world_bare.py diff --git a/asyncio_slow/test_hello_world_bare.py b/asyncio_slow/test_hello_world_bare.py new file mode 100644 index 00000000..1f8d9702 --- /dev/null +++ b/asyncio_slow/test_hello_world_bare.py @@ -0,0 +1,12 @@ +#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() +asyncio.Task(greet_every_two_seconds()) +loop.run_forever()