This is all working great for me. BUt, there's one thing that's missing. The
connections will timeout after a while, and ithe pool will end end up with a
bunch of useless connections that don't work.
How do we handle that?
Geoff Talvola wrote:
> Daniel Green wrote:
> > The reason I wrote PooledConnection the way I did was so that existing code
> > could be ported easily, and the close statement would still do something. I
> > tried the __del__ method, but it's not entirely reliable. Objects apparently
> > don't get __del__'ed as soon as they go out of scope (as I had hoped) so:
> Unlike C++, in Python there is only one local scope for the whole function --
> indented blocks don't form their own scope. So class2 is still in scope after
> the while loop breaks; it only goes out of scope when the function exits.
> > class X:
> > def __del__(self):
> > print "closing"
> > class1 = X()
> > while 1:
> > class2 = X()
> > print "Class2 should close now:"
> > break
> > print "Class1 should close now:"
> > actually prints this:
> > Class2 should close now:
> > Class1 should close now:
> > closing
> > closing
> > So garbage collection isn't happening at the end of the while loop, as I had
> > hoped it would.
> > But since your class works exactly like mine does, with the added bonus of
> > eventual cleanup, I certainly don't see anything wrong with it.
> In case you missed it, I also fixed a typo in the call to returnConnection.
> - Geoff Talvola
> Parlance Corporation
> Webware-discuss mailing list