Twisted: Bye for Now

3 AM May 25, 2004

Back in February, I decided to write my blogging software—KangaPy—in Twisted.

For those who have it come across it before, Twisted is a single threaded, “event-driven networking framework.” The price of using Twisted is that your code must never block on I/O. Instead, the code must return a “Deferred” object that contains a callback which is fired when the I/O operation completes.

In return for writing your code inside-out, Twisted gives you a framework that scales well, freedom from multi-threading concurrency issues and a very clear idea of how your application interacts with the outside world.

Aside from that, Twisted has three1 big pluses:

  1. An active, helpful user community,
  1. Support for a wide range of internet protocols, and
  1. The cutest web framework/HTML generation/templating system I have seen, Nevow.

Unfortunately, a blog with a simple web interface on one end and an RDBMS on the other is not a good fit to Twisted. Since KangaPy is due a major refactoring, I had to decide whether to stay with Twisted (and start using Nevow) or move to a different framework.

I decided to port KangaPy to another framework. This will most likely be CherryPy with Cheetah templates, but time will tell.

I’m glad I decided to give Twisted a go, because the experience may well turn out to be useful in other contexts. I’ve already had one project for which Twisted would have been a great choice, except that my client needs it done in Java.

And finally, a big thanks to Matt Goodall and Donovan Preston for taking the time to point me to Nevow. I played with the tutorials, and it looks great. If you ever manage to make Nevow useful without Twisted, I’d be very interested.


1 This is just my opinion, formed in the light of limited experience.

By alang | # | Comments (17)
(Posted to Python)
© 2003-2006 Alan Green