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

Jeremy Hylton jeremy@zope.com (Jeremy Hylton)
Fri, 31 Jan 2003 16:04:17 -0500


>>>>> "CR" == Christian Reis <kiko@async.com.br> writes:

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

I can see why you would expect this from close().

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

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

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

Right on both points.

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

An __del__ method isn't going to work, because the database always has
a reference to the connection.  It's not going to be collected until
the database is closed and the thread releases its reference.  The
database must have a reference to the connection, otherwise it would
be unable to reuse it.

Jeremy