On Nov 15, 2012, at 7:26 PM, Carl Meyer wrote:

> Hi,
> 
> I'm using SQLAlchemy's connection pool implementation directly (via
> manage() and _DBProxy), and it seems to me that _DBProxy does not
> dispose of its pools/connections the way that the
> documentation/docstrings/method names seem to imply it would.
> 
> The _DBProxy.dispose method docstring says that it will "dispose the
> pool referenced by the given connect arguments", but it doesn't ever
> call dispose() on the pool (which would actually close the db
> connections), it just removes the pool from its internal mapping of
> pools. The effect of this is that idle connections in the pool remain
> open until the process ends. Here's example code:

that's possible, it's a pretty old, little used, API, and that document 
probably assumes GC will pick up on it, and it would be better if dispose() was 
called on the pool all the way through.   But the garbage collector should be 
reclaiming the pool and those connections (all DBAPIs I'm aware of release 
TCP/IP connections when the connection is garbage collected).  Even calling 
gc.collect(), you're not seeing anything clear out ?

> It seems that perhaps _DBProxy is relying on garbage collection to
> somehow clean everything up once it lets go of its reference to the
> pool, but even on CPython with refcounting GC this does not seem to
> work;

CPython clears unreachable cycles periodically as well.  calling gc.collect() 
will force this process to occur.

> Maybe some
> previous version of Pool had a __del__ method that called its dispose
oh.  actually there's a __del__ on _DBProxy and that's probably why 
gc.collect() isn't doing it (it interferes with cyclic GC).

your best bet for now is to just iterate through db.proxy.pools and just call 
dispose() on them.   

http://www.sqlalchemy.org/trac/ticket/2609 is added.



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to