Skip to content

Commit 2c3e360

Browse files
Recommend ASGI integration for Sanic in Documentation
1 parent 104d656 commit 2c3e360

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

docs/server.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,25 @@ Deployment Strategies
628628
The following sections describe a variety of deployment strategies for
629629
Socket.IO servers.
630630

631+
Uvicorn, Daphne, and other ASGI servers
632+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
633+
634+
The ``socketio.ASGIApp`` class is an ASGI compatible application that can
635+
forward Socket.IO traffic to an ``socketio.AsyncServer`` instance::
636+
637+
sio = socketio.AsyncServer(async_mode='asgi')
638+
app = socketio.ASGIApp(sio)
639+
640+
If desired, the ``socketio.ASGIApp`` class can forward any traffic that is not
641+
Socket.IO to another ASGI application, making it possible to deploy a standard
642+
ASGI web application and the Socket.IO server as a bundle::
643+
644+
sio = socketio.AsyncServer(async_mode='asgi')
645+
app = socketio.ASGIApp(sio, other_app)
646+
647+
The ``ASGIApp`` instance is a fully complaint ASGI instance that can be
648+
deployed with an ASGI compatible web server.
649+
631650
Aiohttp
632651
~~~~~~~
633652

@@ -691,6 +710,10 @@ The tornado application is then executed in the usual manner::
691710
Sanic
692711
~~~~~
693712

713+
Note: Due to some backward incompatible changes introduced in recent versions
714+
of Sanic, it is currently recommended that a Sanic application is deployed with
715+
the ASGI integration instead.
716+
694717
`Sanic <http://sanic.readthedocs.io/>`_ is a very efficient asynchronous web
695718
server for Python 3.5 and newer.
696719

@@ -726,17 +749,6 @@ setting in addition to any other configuration that you use::
726749

727750
app.config['CORS_SUPPORTS_CREDENTIALS'] = True
728751

729-
Uvicorn, Daphne, and other ASGI servers
730-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
731-
732-
The ``socketio.ASGIApp`` class is an ASGI compatible application that can
733-
forward Socket.IO traffic to an ``socketio.AsyncServer`` instance::
734-
735-
sio = socketio.AsyncServer(async_mode='asgi')
736-
app = socketio.ASGIApp(sio)
737-
738-
The application can then be deployed with any ASGI compatible web server.
739-
740752
Eventlet
741753
~~~~~~~~
742754

0 commit comments

Comments
 (0)