Why use Tornado and Flask together?

3k- picture 3k- · Oct 31, 2012 · Viewed 42.4k times · Source

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?

Answer

Nathan Villaescusa picture Nathan Villaescusa · Oct 31, 2012

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 + templates 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.