On Apr 9, 2012, at 3:25 PM, Claudio Freire wrote:

> On Mon, Apr 9, 2012 at 4:03 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
>> close your connections after you are finished with them.
> 
> They should be automatically returned to the pool when unreferenced.
> 
> The OP may be storing stray references somewhere, or associating them
> somehow to a reference cycle that takes time to be freed.
> 
> In any case, explicit closing may not be the greatest idea (that
> connection won't go back to the pool I think, not sure, please SA
> gurus confirm), rather, they should be de-referenced thoroughly.

Code that deals with Connection explicitly should definitely have an explicit 
plan in place to close them (where "close" on Connection will return the DBAPI 
connection to the pool).    Relying on dereferencing is not very clean and also 
doesn't work deterministically with environments like Pypy and jython that 
don't use reference counting.

Using context managers, i.e. "with engine.connect() as conn", is the most 
straightforward.


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

Reply via email to