From 23b4b20b4fc48f9087d99b97b16cbc7d4e1ab8bd Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Tue, 2 May 2017 22:44:42 -0700 Subject: [PATCH] document create_server method --- docs/sanic/deploying.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/sanic/deploying.md b/docs/sanic/deploying.md index cc89759b..6a41f08e 100644 --- a/docs/sanic/deploying.md +++ b/docs/sanic/deploying.md @@ -56,3 +56,17 @@ for Gunicorn `worker-class` argument: ``` gunicorn --bind 0.0.0.0:1337 --worker-class sanic.worker.GunicornWorker ``` + +## Asynchronous support +This is suitable if you *need* to share the sanic process with other applications, in particular the `loop`. +However be advised that this method does not support using multiple processes, and is not the preferred way +to run the app in general. + +Here is an incomplete example (please see `run_async.py` in examples for something more practical): + +```python +server = app.create_server(host="0.0.0.0", port=8000) +loop = asyncio.get_event_loop() +task = asyncio.ensure_future(server) +loop.run_forever() +```