[Twisted-Python] What's everyone using Twisted for?

Andrew Bennetts andrew-twisted at puzzling.org
Thu Dec 13 08:52:50 EST 2001

Ok, so here's a quick summary of what I use Twisted for...

I'm a developer for a company that processes stock data and publishes it
via the web and our own proprietary protocol.  While the bulk of our
systems are written in C++, I occasionally manage to do some things in
Python which the C++ developers think would be too tedious (but are
actually pretty simple in Python).

My C++-coding colleagues were concerned that a moderately important
server I proposed to write in Python wouldn't be fast enough, and that
I'd end out using something dodgy like one thread per socket which would
kill performance.  Our systems all run on Win 2000, and many of the C++
servers make use of relatively obscure features like IO completion ports
to improve performance.

So I used Twisted.  It is just beautifully simple to write an
asynchronous, single-threaded server with Twisted.  I've got a Python
implementation of our internal protocol that inherits from
twisted.protocols.protocol.ServerProtocol, and by writing a class which
inherits from my class and overrides a single method, "queryRecevied",
you can write a server for our systems.  At least one of the C++
developers is now talking about writing his next server in Python.

As for the speed, I'm getting nearly 200 requests/sec for this
particular application, which is without doing any sort of optimisation,
and involves processing by other servers due to the design of our
company's systems, and involves processing XML in my server.  This
compares nicely with our C++ servers :)

I haven't yet looked at half the things that Twisted can do (in
particular, I'm interested in seeing if twisted.enterprise supports MS
SQL Server 7 via the ADODB COM objects, or is easily adapted to it)....
but I'm looking forward to finding out.  Twisted makes writing a
scalable server disgustingly easy.

I regret that I cannot mention specific products -- this is all
closed-source stuff used internally.  

I'm using Twisted 0.12.3, but am looking forward to the next version
which will presumably fix the bug where startFactory gets called twice

The only real problems I've had with Twisted so far are:
  * Having to admit that I need to delete those 50 lines of code because
    Twisted makes me realise I can do it in 15
  * Trying to figure out how to make Twisted do everything for me, when
    it turns out that I really just needed something incredibly simple.
    (I got so used to thinking Twisted's framework could do it all, I
    started to muck about with Deferreds, until I realised that I just
    wanted keep a list of functions to run as soon as another function
    finished, which is something you can do with vanilla Python
    perfectly well :)
  * Having a semi-legitimate reason to IRC from work, so I can ask the
    friendly people on #python questions about Twisted :)

Oh yes, and I'd like to mention that I like how if Protocol.dataReceived
for some reason throws an exception, Twisted keeps on working (after
logging the exception), rather than killing the whole server.  I realise
it's a simple thing, but I'm glad it's been done.

I'm also interested in run-time configuration/status info -- am I right
in believing there is a simple way to create a web interface for
inspecting a Twisted application?  (Our systems typically export a COM
interface which is then manipulated by VB apps, but exporting COM
interfaces from NT services in Python is a bit messy). 

Hmm.  That wasn't as quick as I intended, but I hope you find it to be
of some use.

Keep on Twistin'...


More information about the Twisted-Python mailing list