[ZODB-Dev] Opening 7 Connections hangs (and __del__)

Christian Reis kiko@async.com.br
Fri, 31 Jan 2003 13:32:17 -0200


On Fri, Jan 31, 2003 at 09:57:12AM -0500, Chris McDonough wrote:
> You are exhausting the connection pool, and the database can't give you
> a connection via db.open() because it's waiting for a connection to
> become free out of the connection pool.  This limit can be increased via
> the pool_size parameter of DB's constructor, but you do need to close
> connections when you are finished with them (which will return them to
> the pool).

Aha. Okay, this makes sense - I *do* need to call close(). That's what
tickles them. Thanks, I was mistakenly understanding close() shouldn't
be called as it would destroy the connection.

So in summary: when using multiple connections to a database: 

    a) Make sure to have the pool size as big as the number of multiple
    simultaneous connections you require. You can use db.setPoolSize()
    to do this in runtime.

    b) Make sure to call close() after you are done with a connection to
    allow it to be reused.

It's trivial to have a wrapper around connection that takes care of
this, calling conn.close() on __del__ and incrementing the pool size
when another simultaneous connection is required.

Thanks, really.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL