feat(exapmles): add add_task_sanic.py
This commit is contained in:
parent
dd241bd6fa
commit
947364e15f
17
examples/add_task_sanic.py
Normal file
17
examples/add_task_sanic.py
Normal file
|
@ -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)
|
Loading…
Reference in New Issue
Block a user