[Twisted-Python] Need some pointers for writing asynchronous code for Twisted app

Manlio Perillo manlio_perillo at libero.it
Sat Mar 10 05:32:18 EST 2007


Andrew Bennetts ha scritto:
> Brian Costlow wrote:
> [...]
>> So the easy way out, it seems to me, would be to make the LineRecever callback
>> build the ElementTree as I get it. Then wrap minimally modfied versions of the
>> code that processes the ElementTree to the dict, and the dict to the database,
>> in a callInThread or deferToThread call. Which is a lot of use of the thread
>> pool, which seems to violate the idea of a low-overhead asynchronous event
>> loop.
> 
> Most databases don't really give you any choice but to use threads.
> twisted.enterprise.adbapi helps a little.  Compared to the time it takes for the
> database to do its stuff, I doubt you'll notice the thread overhead.
> 

A pure asyncronous database API (written in Twisted), for PostgreSQL 
only, is pgasync
http://jamwt.com/pgasync/
and pglib
http://developer.berlios.de/projects/pglib/


Regards  Manlio Perillo




More information about the Twisted-Python mailing list