From 415af129b756d5e955180af314589bdc0c5930ff Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Thu, 28 Jun 2018 11:16:56 -0700 Subject: [PATCH] Tornado docs --- docs/index.rst | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index df453122..1a26d7a7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,7 +20,8 @@ features: - Compatible with Python 2.7 and Python 3.3+. - Supports large number of clients even on modest hardware when used with an asynchronous server based on `asyncio `_ - (`sanic `_ and `aiohttp `_), + (`sanic `_, `aiohttp `_ or + `tornado `_), `eventlet `_ or `gevent `_. For development and testing, any WSGI compliant multi-threaded server can also be used. @@ -512,6 +513,39 @@ The aiohttp application is then executed in the usual manner:: if __name__ == '__main__': web.run_app(app) +Tornado +~~~~~~~ + +`Tornado `_ is a web framework with support +for HTTP and WebSocket. Support for this framework requires Python 3.5 and +newer. Only Tornado version 5 and newer are supported, thanks to its tight +integration with asyncio. + +Instances of class ``socketio.AsyncServer`` will automatically use tornado +for asynchronous operations if the library is installed. To request its use +explicitly, the ``async_mode`` option can be given in the constructor:: + + sio = socketio.AsyncServer(async_mode='tornado') + +A server configured for tornado must include a request handler for +Engine.IO:: + + app = tornado.web.Application( + [ + (r"/socketio.io/", socketio.get_tornado_handler(sio)), + ], + # ... other application options + ) + +The tornado application can define other routes that will coexist with the +Socket.IO server. A typical pattern is to add routes that serve a client +application and any associated static files. + +The tornado application is then executed in the usual manner:: + + app.listen(port) + tornado.ioloop.IOLoop.current().start() + Eventlet ~~~~~~~~