Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-11-12 Thread Phil Mayers
> Is there a reason why multiprocessing could not be used? > > http://docs.python.org/library/multiprocessing.html#exchanging-objects-between-processes > Yes http://twistedmatrix.com/trac/ticket/3901 ___ Twisted-Python mailing list Twisted-Python@tw

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-11-12 Thread Eero Nevalainen
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/c802749c9d0dd6 > > I've been busy for a long time so I didn't considered this question > anymore. But occasionally, I got some new ideas to

[Twisted-Python] Using sqlalchemy in twisted.

2009-11-11 Thread Peter Cai
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 sand

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-13 Thread luper rouch
2009/3/12 Peter Cai : > Hi, > I've read some mails in this list that recommend use sqlalchemy in separate > processes. > But if u use multiprocessing which provides only synchronous API, doesn't > you have to use deferToThread also? > Another way would be using "twisted.internet.protocol.ProcessPro

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-11 Thread Peter Cai
Hi, I've read some mails in this list that recommend use sqlalchemy in separate processes. But if u use multiprocessing which provides only synchronous API, doesn't you have to use deferToThread also? Another way would be using "twisted.internet.protocol.ProcessProtocol", which use pipes. But ca

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-10 Thread luper rouch
I would recommend sandboxing Twisted code in another process when used in conjunction with synchronous code (sqlalchemy, GUI, etc...). This proved quite simple in my project, using the multiprocessing module [1], and avoided me lots of headaches since. This way I don't mix coding styles everywhere

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Peter Cai
I changed my code to this style, it works again. This code would create a new session on each request and close it immediately. Hope this trick could save me! #= def require_session(f): '''create and close session for each synchronous method''' de

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Peter Cai
I'm not quite sure, but I think I'm pretty careful of sharing objects between threads. 1st, I only cached as few as possible orm objects. I tried to detach them, but I found that if I detach them, I can't access any of their fields any more. 2nd, I create new orm objects based on client request,

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Valentino Volonghi
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mar 4, 2009, at 11:15 AM, Chris Foster wrote: I think SQLAlchemy's ORM might work fine with Twisted. Check out http://foss.eepatents.com/sAsync/ . sAsync doesn't appear to be widely used, but I got the examples to run with some minor change

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Chris Foster
I think SQLAlchemy's ORM might work fine with Twisted. Check out http://foss.eepatents.com/sAsync/ . sAsync doesn't appear to be widely used, but I got the examples to run with some minor changes to the sqlite connection. I'm hoping to try something useful in the next week or two. On Mar

Re: [Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Valentino Volonghi
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mar 4, 2009, at 3:28 AM, Peter Cai wrote: The code doesn't work. When I limit the thread numbers to 1 reactor.suggestThreadPoolSize(1) Everything goes fine. Other wise the server would be blocked and must be killed by "kill 9 ...". The

[Twisted-Python] Using sqlalchemy in twisted.

2009-03-04 Thread Peter Cai
Hi, all I am using sqlalchemy in twisted in my project in the way below. Defer any database operation so the twisted's main thread won't be blocked. And I use scoped_session, so that sessions won't have to be created again and again. == class Database() de