From 947364e15f72aa61b76c6c1246ba1891b8f84417 Mon Sep 17 00:00:00 2001 From: jiaxiaolei Date: Sun, 20 Aug 2017 11:11:14 +0800 Subject: [PATCH] feat(exapmles): add `add_task_sanic.py` --- examples/add_task_sanic.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/add_task_sanic.py diff --git a/examples/add_task_sanic.py b/examples/add_task_sanic.py new file mode 100644 index 00000000..52b4e6bb --- /dev/null +++ b/examples/add_task_sanic.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +import asyncio + +from sanic import Sanic + +app = Sanic() + + +async def notify_server_started_after_five_seconds(): + await asyncio.sleep(5) + print('Server successfully started!') + +app.add_task(notify_server_started_after_five_seconds()) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000)