[Twisted-Python] Using sqlalchemy in twisted.

Peter Cai newptcai at gmail.com
Wed Nov 11 11:55:48 EST 2009


If you Google "sqlalchemy twisted", you can see my post is on the top:

http://groups.google.com/group/sqlalchemy/browse_thread/thread/c802749c9d0dd6

I've been busy for a long time so I didn't considered this question
anymore.  But occasionally, I got some new ideas today.

I was suggested to sandbox sqlalchemy into process contains a single thread.
At that time, I thought it was just the same as using deferToThread
and makes no scenes to have the overhead of IPC.

But now I see the benefits.

A single thread process makes it possible to use a sqlalchemy session
as a cache.  That would greatly reduce the chances to lookup database.
This could not be done with deferToThread because it uses thread pool.
 So there shall be more than one session and the state of cached
objects will conflict.

But there are still one problem : how to transfer a sqlalchemy object
between 2 process?  Some kind of serialization and de-serialization is
needed.  Without test, it's too early to tell if it works.

-- 
look to the things around you,the immediate world around you, if you
are alive,it will mean something to you ——Paul Strand



More information about the Twisted-Python mailing list