Search code examples
pythonwebwebserverflasktornado

Why use Tornado and Flask together?


As far as I can tell Tornado is a server and a framework in one. It seems to me that using Flask and Tornado together is like adding another abstraction layer (more overhead). Why do people use Flask and Tornado together, what are the advantages?


Solution

  • According to this question it is because Flask is blocking and Tornado is non-blocking.

    If one uses Tornado as a WSGI server and Flask for URL routing and templates (undocumented) there shouldn't be any overhead. With this approach you aren't using Flask's web server, so there isn't really an extra layer of abstraction.

    However, if one is using Flask just for the templates they could use Tornado with Jinja2 which is the template engine that Flask uses.