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

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 point).
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 something?
Chris

On Wed, 2005-02-09 at 10:41 -0800, snacktime wrote:
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
adbapi also does thread pooling, not just connection pooling. So it won't start a new thread after the first few queries.

On Wed, 09 Feb 2005 14:48:41 -0500, Itamar Shtull-Trauring itamar@itamarst.org wrote:
On Wed, 2005-02-09 at 10:41 -0800, snacktime wrote:
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
adbapi also does thread pooling, not just connection pooling. So it won't start a new thread after the first few queries.
Ah nice. So I could completely get rid of starting a new thread for every request by using adbapi.
participants (2)
-
Itamar Shtull-Trauring
-
snacktime