[cx-oracle-users] Session Pooling
Brought to you by:
atuining
From: Orr, S. <so...@ri...> - 2005-08-01 17:28:20
|
I'm looking to use session pooling for performance (Apache 2.0, mod_python, Quixote 2.0, cx_Oracle 4.x Oracle9). Here's some code for reference: import cx_Oracle class dbconnect(cx_Oracle.Connection): def __init__(self, user=3DNone, password=3DNone, dsn=3DNone, = pool=3DNone): cx_Oracle.Connection.__init__(self, user=3Duser, password=3Dpassword, dsn=3Ddsn, pool=3Dpool) self.pool =3D pool def close(self): self.pool.release(self) class dbfun(object): def __init__(self): self.pool =3D cx_Oracle.SessionPool('user', 'pw', 'local', 1, 8, 1) self.pool.timeout =3D 30 def connect(self, user, password, dsn): conn =3D dbconnect(user=3Duser, password=3Dpassword,=20 dsn=3Ddsn, pool=3Dself.pool) return conn Basically I subclassed the cx_Oracle connection object to over-ride the close function to release a connection to the pool instead of closing it.=20 Observations and Questions: Setting the timeout attribute doesn't seem to change anything, no connections are returned to the pool after 30 seconds. Is this a bug or am I doing something wrong?=20 If I exceed the session limit from Python it just hangs... Shouldn't cx_Oracle.Connection return an exception? Do I really HAVE to compare pool.busy and pool.opened in my code and raise my own exception?=20 I found that if I kill a session from SQL*Plus it does not become available to the pool. Well okay. I found that when connecting through my dbfun class I could connect with a different user/password than was established in the pool. What are the ramifications of this? If I want to pool connections from different users do I need to create distinct pools for each user ID? Are there any other suggestions or sample code on how to implement connection pooling? Has anyone cached cursors and is it worth it?=20 TIA, Steve Orr |