From 0ef4fbfeeb188a76095de2631cdef9ab4f01839d Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Thu, 28 Jun 2018 11:16:30 -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 aaec4df9..44004717 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,7 +15,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. @@ -203,6 +204,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 ``engineio.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:: + + eio = engineio.AsyncServer(async_mode='tornado') + +A server configured for tornado must include a request handler for +Engine.IO:: + + app = tornado.web.Application( + [ + (r"/engine.io/", engineio.get_tornado_handler(eio)), + ], + # ... other application options + ) + +The tornado application can define other routes that will coexist with the +Engine.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 ~~~~~~~~