Hacker News new | ask | show | jobs
by frognibble 5755 days ago
The Tornado philosophy is to use blocking for fast operations and async for the occasional long operation. Tornado applications compensate for blocking by running several instances of the application.

Twisted is theoretically better than Tornado because everything is async in Twisted, but Tornado is more practical because it's easier to write straight-line code than chains of callbacks. The cost of Tornado is that you need more memory on the frontend because you run more instances of the application.

In my previous comment, I listed some real life comet applications that use Tornado. What real life comet applications use Twisted?

1 comments

@inlineCallbacks make linear code very easy to write in twisted. Have you tried it lately? Here's a snippet of code out of my gearman implementation:

    @defer.inlineCallbacks
    def gclient(gearman):
        w = client.GearmanClient(gearman)
        x = yield w.submit('test', 'some data')
        print "result:", repr(x)
Pretty straighforward, I think -- you just stick a 'yield' between your invocation and the capture of the results.

As far as who's using in actual comet applications -- it's hard to say. The last time I tried looking for a comet implementation, what appeared to be the canonical "cometd" was written in twisted. I ended up not using it and rolled my own twisted based server that was closer to my requirements. It's been in production for a few years now, but is still a somewhat secret project.

I'm pretty sure you could research their userbase as well as I could.

I'm not saying twisted is perfect and all other technology sucks (though deferreds, once you understand them, are really the only way to do this sort of thing).

When tornado was launched, I started playing with it and couldn't understand why it prevented me from integrating so many asynchronous tasks. I spent an hour or two separating the good parts of tornado from the reimplementation of twisted and built tornado on top of twisted. It was, as far as I could tell, at the starting point, minus 1,297 lines of python.