[Twisted-Python] twisted.enterprise.adbapi appropriate?

snacktime snacktime at gmail.com
Wed Feb 9 13:41:51 EST 2005

Say I have a client/server application where the sequence basically
goes like this:

1. client connects
2. server queries database
3. server uses results of query to do blocking operation (http POST to
another server)
4.  server inserts some data into database (1-3 inserts)
5. server sends reply to client

Right now 2-4 is all in a single method that I just call with
deferToThread, and the callback takes care of 5.

I'm trying to understand what advantages I would get from doing this:

- convert 2 and 4 to use twisted.enterprise.adbapi.
- change 3 to use twisted.web.client.
- then restructure the code a bit so I'm not calling 2-4 in a single
method via deferToThread (since nothing would be blocking at this

If twisted.enterprise.adbapi is going to open a new thread anyways,
what advantages would there be to restructuring my code as outlined
above?  The only thing I can think of is that I would get connection
pooling and not have to open/close a new connection on each request
(which is definitely a plus).  Am I on track here or am I missing


More information about the Twisted-Python mailing list