Re: [cx-oracle-users] is SessionPool thread safe?
Brought to you by:
atuining
From: Forest W. <mo...@ti...> - 2005-09-15 16:59:52
|
Thanks for the response, but I'm afraid it doesn't explain the matter. It tells me how Connection objects behave when shared among threads, but it does not tell me how SessionPool objects behave when shared among threads. One interpretation of what you wrote (and of the documentation) is that SessionPool.acquire() returns a thread-safe object when it was constructed with threaded=True, but the SessionPool.acquire() call itself is not thread safe. If that is the case, a program's main thread could safely acquire() Connections and then pass them to worker threads, but multiple worker threads could not safely call acquire() on their own. My program's worker threads have to acquire() Connections on an as-needed basis, rather than being handed a Connection when they start up. The answer to my question will determine whether I have to write my own synchronization wrapper for SessionPool.acquire(). Anthony Tuininga <ant...@gm...> wrote: > If you specify "threaded =3D True" in the constructor of the session > pool, Oracle guarantees thread safety provided you use one thread for > each connection you use. If you want more than one thread to access a > connection, you will have to synchronize access. Does that explain the > matter sufficiently? > > On 9/12/05, Forest Wilkinson <mo...@ti...> wrote: > >>I'm using cx_Oracle SessionPool objects in a threaded http server. Since >>I didn't see an explicit statement in the docs that SessionPool.acquire() >>and SessionPool.release() are thread safe, I'm currently synchronizing >>access to those methods with a threading.Condition object. Is this >>necessary? If SessionPool does its own method synchronization, I'll get >>rid of my wrapper class and perhaps get better performance. >>=20 >>=20 |