[Twisted-Python] SQLAlchemy, Twisted, and sAsync

Matthew Williams mgwilliams at gmail.com
Fri Mar 26 08:09:49 EDT 2010

On Mar 26, 2010, at 3:20 AM, Chris Withers wrote:

> Matthew Williams wrote:
>> From previous posts to this and other lists, it seems that ORMs  
>> and  threads don't get along too well...
> What makes you think that?

First of all, most of my impressions about ORMs come from SQLAlchemy.   
This quote from this list (http://twistedmatrix.com/pipermail/twisted-python/2009-March/019359.html 
) sums up what I have found as well:

"It's much trickier if you want to use the ORM, unless you are very
careful to fully eager load every thing in any possible database
operation if you have need of the information subsequently in your
twisted code. Otherwise you may block unexpectedly simply when
accessing your objects, and end up with database operations from the
main twisted thread."

So perhaps I should have said "SQL Alchemy's ORM and threads don't get  
along too well"... that's not to say it's impossible, you just have to  
be exceedingly careful how you use it.

>> and, as far as I can tell, there's  no way to get away from threads  
>> if you don't want longish queries to  block your entire application.
> Right, SQLAlchemy doesn't play nicely with *non-threaded*  
> environments, from my understanding, which may well be wrong ;-)
>> It took me quite some time to piece together everything I could  
>> find  related to sAsync (which seems to be a dead but functional  
>> project),  so I threw up a quick Trac page for it at http://sasync.org 
>> .
> Cool. What is it you're doing that needs to mix Twisted and  
> SQLAlchemy?

The project (an internal project) doesn't really *need* to mix them...  
I could just use mysqldb.


More information about the Twisted-Python mailing list