On Mon, 2002-10-28 at 10:31, Stefan Schwarzer wrote:
> Hi Edmund
> On Mon, 28 Oct 2002, Edmund Lian wrote:
> > >Could the problem of leaking DB connections be at all related to how DBPool.py
> > >doesn't actually close connections on being deleted? I'm actually using
> > >multiple instances of a refactored version of DBPool.py to maintain multiple
> > >pools. The code doesn't actually close the connections when the instance is
> > >deleted.
> > OK, I've educated myself--sort of... I added code to close connections, and
> > called the code from __del__ definitions. It doesn't help since the restart
> > doesn't seem to call __del__ at all. A real shutdown of the app server does
> > cause __del__ to be called. Why is this (just asking to understand what's
> > going on)?
> The actual __del__ will only be called when the object which contains
> the __del__ method is garbage-collected, i. e. when there are no more
> references to the object. It seems that the exec doesn't affect the
> existing references which is in line with the observations that
> started this discussion.
Correct: exec doesn't give the Python interpreter a chance to clean
everything up; it re-loads the current process immediately (the call
never returns). It would be better if we did give Python a chance to
clean things up, though, so I'm going to change the implementation to
not use exec(). I'll post more details later today.
Jason D. Hildebrand