[Twisted-Python] Newbie - how to modify my db-intensive app to use Twisted

Marcin Kasperski Marcin.Kasperski at softax.com.pl
Sun Nov 20 06:44:40 EST 2005

> Moving this concept onto Twisted does not seem to work, as it can be running
> sessions for multiple users, and each 'block' will block the main loop,
> resulting in a major performance hit. The correct solution, as I understand
> it, is to change each SQL command to a deferred with a callback. I can do
> this on the inner layers, where the actual SQL command is executed. But I
> would also have to do it on each outer layer that calls a function which
> 'may' trigger a SQL command. There are many of these, and it goes to the
> heart of my approach of hiding the underlying database complexity from the
> application layer. Changing this feels like a daunting task, and frankly I
> would not know where to start.

Not quite sure what exactly your code does, but what about taking a look
at twisted.enterprise.adbapi (and especially runInteraction)? Maybe
executing your code within runInteraction could be quick solution (in
fact the code will run in separate thread silently created by twisted
for you) - and then you could try to optimize things one by one.... 

More information about the Twisted-Python mailing list