7 ms·
Tornado 2.0 released
- MostAwesomeDude 15y agoI know that nobody outside of the Python community cares, but it's disappointing to see that Tornado still doesn't use Twisted for its event handling.
- simonw 15y agoWhat advantages would switching to Twisted bring to the Tornado project?
- ivank 15y agoSee "if it used Twisted for the event loop and none of the HTTP stuff:" at http://glyph.twistedmatrix.com/2009/09/what-i-wish-tornado-were.html http://glyph.twistedmatrix.com/2009/09/what-i-wish-tornado-w... (Some of these things might have been fixed, I haven't checked)
- wisty 15y agoI think that's because Tornado is fantastically simple, and Twisted just isn't. Tornado is the bare-bones essentials for an async web application server. Twisted is not. You can start with Tornado, then put Django or Twisted on top, but that's optional. Besides, people are kind of scared of Twisted.
- dirtyaura 15y agoI really like that Tornado is a small, self-contained project. I can read through the whole codebase and understand it. Twisted is quite large nowadays http://twistedmatrix.com/trac/browser/trunk/twisted http://twistedmatrix.com/trac/browser/trunk/twisted Compare it to Tornado source, which is ~30 Python files https://github.com/facebook/tornado/tree/master/tornado https://github.com/facebook/tornado/tree/master/tornado
- intranation 15y agoI think it's safe to say a lot of people inside the Python community don't care either. Twisted is incredibly complex and competition in the asynchronous networking space can only be a good thing.
- cdavid 15y agoI don't know if that many people inside the python community care either. Twisted is very big, documentation seriously lacking, and a lot of stuff in twisted not that useful if you only care about http. If you care about http, twisted is not that useful either (there is for example no http 1.1 support client-side AFAIK). It would also have made porting tornado to python 3 a huge effort (given twisted code size).
- hyperplex 15y agohttp://twistedmatrix.com/trac/browser/trunk/twisted/web/_newclient.py#L5 http://twistedmatrix.com/trac/browser/trunk/twisted/web/_new... I run a web crawler out of Twisted, so I sort of care about HTTP.
- cdavid 15y agoI am aware of that code: it is undocumented, and does not have support for things as fundamental as keep alive. The underscoring does not inspire confidence either.
- ivank 15y agoYou're meant to use the public API twisted.web.client.Agent (which uses _newclient). If anyone's interested in finishing keep-alive support, the ticket is http://twistedmatrix.com/trac/ticket/3420 http://twistedmatrix.com/trac/ticket/3420
- davidhollander 15y agoWhy would it switch to Twisted if it has always had its own lightweight event loop that's always benchmarked significantly faster? Same goes for fapws3 and gevent.
- cdavid 15y agoI can see a lot of reasons to use tornado instead of twisted, but speed is not really one of them. I have not seen a non-trivial benchmark showing one faster than the other (and tornado devs recognize themselves that speed was not that different between the both of them).
- rabidsnail 15y agoThere are some philosophical reasons for not using twisted's io loop (for example, because it uses ctypes to interface with epoll et al, or because of the FactoryFactoryFactory Java envy). As was mentioned already, competition is good.
- ivank 15y agoTwisted doesn't use ctypes to interface with epoll, it uses a Cython module. Also, the Factory stuff in Twisted usually makes sense, as the alternative is worse (some object in a long-lived closure).
- perfunctory 15y ago> it's disappointing to see that Tornado still doesn't use Twisted not using Twisted was the whole point of Tornado, wasn't it? If Tornado used Twisted it wouldn't exist.
- deleted 15y ago[deleted]
- nikcub 15y agowhen Tornado was first released, there was a lot of discussion online on various forums and comment threads about why it wasn't built on top of Twisted, or why it was a complete separate project. I tend to agree with Brett Taylor in that Twisted was too large a project to suit the goals of Tornado, and that its own divisions within twisted.web were difficult to navigate through the event handling part of Tornado is less than 100 lines of code and is a lot easier to implement and understand than Twisted, although Twisted also serves a purpose. I like and prefer that Tornado is self-contained and focuses on a single use case (returning JSON in long-polls) and does it well
- dlsspy 15y agoWhen the original twisted code was released, I removed 1,297 lines of code to port it to twisted and gained a lot of functionality (tornado has just about no support for doing anything async). Not sure where you get less than 100 lines. http://dustin.github.com/2009/09/12/tornado.html http://dustin.github.com/2009/09/12/tornado.html
- gsk 15y agoI stand on the other end. The reason why I choose tornado for my startup was because it did not use twisted (too early for twisted in my project). Tornado has a great modular structure so you can use each module on its own. The code is lovely to look at too.
- icey 15y agoYou can have Tornado on Twisted, if you really want it: https://github.com/fiorix/cyclone https://github.com/fiorix/cyclone I have used this in a few applications and really liked it. They've historically kept up with new Tornado releases, so hopefully they'll catch up with Tornado 2.0
- MostAwesomeDude 15y agoI'm glad to see that, out of all the top-level comments, the ones about Flask and Jinja2 were not highly criticized, but I will never understand the rather massive butthurt that this community seems to feel over Twisted. Is it because people love Tornado, or because people hate Twisted? Also, as always, since somebody said "Twisted is big," I'd just like to counter: Django is twice as big as Twisted and nobody seems to mind.
- lolaa 15y agoCool blog you have here, I will check in often. Best Wishes, <a href="http://www.letarot.fr>tarot</a> http://www.letarot.fr>tarot</a>
- lolaa 15y agoI found your blog by chance and I like it a lot. [url=http://www.etoiledevenus.com]voyante[/url] http://www.etoiledevenus.com]voyante[/url]
- nikcub 15y agocan not understate just how well written Tornado is. If you are a web app developer, it is well worth reading the source of the project - you will pick up a lot of tips and tricks on developing quick and scalable apps. outside of the event loop implementation, the framework components are well written - so tornado is worth checking out even if you are running on a more standard type of web server environment or appengine my own web app stack contains a number of modules either directly from Tornado or inspired by sections of the project
- IgorPartola 15y agoI found some parts of it to be very poorly written. Like the error handling where it assumes you want to return HTML (remember that Tornado was first written to handle RSS feeds). It also has really poor support for multiprocess mode, where if a child gets killed , the parent does not restart it. Or if the parent is killed, the children may continue running. Also the gzip implementation is broken: if the client mentions gzip even as q=0, Tornado will use it. Just feels like the devs did not not quite pay attention to the details as much as the event loop.
- jrussbowman 15y agoThere's never been a real focus on multiprocess. The recommended solution is to run individual instances and load balance them with something like nginx and manage them with supervisord. Sure the multiprocess stuff is in there, but I honestly wouldn't use it for more than perhaps a dev environment where you want to spool up multiple instances quickly for testing.
- BarkMore 15y agoLike the error handling where it assumes you want to return HTML (remember that Tornado was first written to handle RSS feeds). You can override the error handler and return whatever content type you want. Tornado was first written for an HTML site, not RSS feeds. FriendFeed supported an HTML UI before Atom and RSS feeds were added. really poor support for multiprocess mode The Tornado people do not recommend using multiprocess mode. They should just delete this code.
- deleted 15y ago[deleted]
- jokull 15y agoAnyone know why they didn't go with Jinja2 for templates? When code is this clean I'm sympathetic towards the "batteries-included" approach, so I'm not criticizing the choice, just wondering if there was a back story, if it got evaluated at all. Same for locale.py vs. PyBabel. The template engine seems far better than Django's at least : )
- rgarcia 15y agoMy guess is that they wanted to go the "self-contained" route as opposed to the "amalgamation of different libraries" approach (a la Pylons/Pyramid). This makes it a lot easier to learn for true beginners since it eliminates the overhead of navigating the documentation of a multitude of different libraries . Tornado is so flexible, though, that it would be pretty straightforward for you to use whatever templating library floats your boat.
- antihero 15y agoWhat exactly is the reason for using Tornado over something like Flask+Gunicorn+meinheld? Preference?
- jrussbowman 15y agoPreference is generally the reason for choosing any framework. What Tornado provides is a small but well featured framework for building web applications. It's event loop based which allows it to support lots of connections. It also has been built from the ground up with the idea of horizontal scaling of it across multiple load balanced instances so if that's your plan for scaling you know it fits the mold well.