为什么要一起使用龙卷风和烧瓶? [英] Why use Tornado and Flask together?

查看:127
本文介绍了为什么要一起使用龙卷风和烧瓶?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,龙卷风是一个服务器和一个框架。在我看来,一起使用Flask和Tornado就像添加另一个抽象层(更多的开销)。为什么人们一起使用Flask和Tornado有什么优势?根据 解析方法 stackoverflow.com/questions/8143141/using-flask-and-tornado-together\">这个问题,这是因为烧瓶阻塞和龙卷风是非阻塞的。



如果使用 Tornado作为WSGI服务器并使用Flask进行网址路由+模板,不应该有任何开销。使用这种方法,您不使用Flask的Web服务器,所以实际上并没有额外的抽象层。



但是,如果使用Flask仅仅用于模板他们可以通过 Jinja2 来使用Tornado,这是Flask使用的模板引擎。

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?

解决方案

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.

这篇关于为什么要一起使用龙卷风和烧瓶?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆