[Twisted-Python] Using sqlalchemy in twisted.

If you Google "sqlalchemy twisted", you can see my post is on the top: http://groups.google.com/group/sqlalchemy/browse_thread/thread/c802749c9d0dd... 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

Peter Cai wrote:
If you Google "sqlalchemy twisted", you can see my post is on the top:
http://groups.google.com/group/sqlalchemy/browse_thread/thread/c802749c9d0dd...
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.
Is there a reason why multiprocessing could not be used? http://docs.python.org/library/multiprocessing.html#exchanging-objects-betwe... -- Eero Nevalainen

Is there a reason why multiprocessing could not be used?
http://docs.python.org/library/multiprocessing.html#exchanging-objects-betwe...
participants (3)
-
Eero Nevalainen
-
Peter Cai
-
Phil Mayers