Differences between gevent and tornado

前端 未结 2 652
礼貌的吻别
礼貌的吻别 2021-01-31 00:27

I understand that both tornado and gevent are asynchronous python frameworks.

While reading the bottle documentation I found that gevent actual

相关标签:
2条回答
  • 2021-01-31 01:08

    Have a read of:

    http://en.wikipedia.org/wiki/Coroutines

    and:

    http://en.wikipedia.org/wiki/Event-driven_architecture

    http://en.wikipedia.org/wiki/Event-driven_programming

    The gevent package uses coroutines and Tornado is event driven.

    Even driven systems don't readily map to WSGI, but a coroutine system, because it looks like threads, can be made to support WSGI if blocking points can be patched to switch coroutines when things would block.

    0 讨论(0)
  • 2021-01-31 01:08

    gevent and Tornado are a bit different. gevent is much more like Twisted - an asynchronous network framework, whereas Tornado is a web only framework.

    The main highlight of gevent is that it utilizes coroutines and makes code look like it's running synchronously, but in fact most IO blocking functions are non-blocking and return control to the gevent main loop. This is very important for IO bound programming since it allows you to write highly efficient single thread code the same way you would write multithreaded code, which is much more resource hungry.

    gevent also includes a WSGI request handler so it can be used to handle HTTP requests in a standalone manner, like Tornado.

    Tornado is an asynchronous web framework which relies on the programmer to write asynchronous code in Python, which is often a pain in the Backend because there are no multiline anonymous closures or classes, like in JavaScript or Java. Therefore, writing good code using Tornado is really hard. For example, using blocking libraries becomes a pain.

    Indeed both frameworks are asynchronous at their core, but the resulting code looks a bit different (easier to program with gevent).

    You can actually use Torando and gevent together, but I haven't tried it out (yet).

    0 讨论(0)
提交回复
热议问题