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

Andrew Bennetts andrew-twisted at puzzling.org
Sat Mar 10 20:35:24 EST 2007


Brian Costlow wrote:
[...]
> So, my current plan is to refactor the tree-->dict code, but call that in a
> separate thread. Rewite the dict --> db layer. The only question I have, is
> since it's a long series of insert/update calls in which I don't need results
> other than, 'it worked' , is, after reading the comments, it seems like I might
> just best be served by writing a series of straight dbi calls; and wrapping
> that all in one call to thread.callInThread.
> 
> The db is MySQL, and feeds a PHP-based reporting app, so I can't use pgasync.

You can use twisted.enterprise.adbapi, though.  You'd want to use
ConnectionPool.runInteraction.  It might be slightly easier than doing it
yourself with callInThread.

-Andrew.





More information about the Twisted-Python mailing list