Garanin Michael wrote:
> Hello!
> I have situation: 
> 1) I have PostgreSQL database: max-connection == 5
> 2) I have one IZopeDatabaseAdapter
> 2) I create 10 threads and join's (!!!)  to main thread
> 2.1) In each thread i get IZopeConnection from IZopeDatabaseAdapter
> 2.2) execute simple select-statement & call transaction.commit
> Result: sometimes (~ 1/10) i get exception "connection limit exceeded". 
> I think: problem is safety stopped threads (and his locals) in memory
> along short time => connections also in memory short time and not
> destroed and not closed. Of course, i can call 'disconnect' every time,
> but it's bad.
> May be make connections-pool (only da with threadsafety==2) and after
> transaction.commit\abort move connection to connections-pool for use in
> other threads?

I would wrap pyPgSql instead and put your connection pool in at this level.
Other database adapters (such as psycopg2 I believe) already have connection
pooling and ensure that the connections are properly reset before being
reused. Your pyPgSql with connection pooling can then be used for other
Python applications, and you don't have to reengineer special
ZopeDatabaseAdapters to handle threadsafety>2 drivers.

(In fact, there is probably a generic connection pooling wrapper already

You still have the issue of what to do when Zope needs the 6th connection -
block or raise an exception?

Stuart Bishop <[EMAIL PROTECTED]>

Attachment: signature.asc
Description: OpenPGP digital signature

Zope3-dev mailing list

Reply via email to