On Jun 29, 2010, at 5:41 PM, Wyatt Lee Baldwin wrote:

> 
> It's a fairly standard multi-threaded Pylons Web app that calls
> Session.remove() at the end of each request. All DB operations go
> through the ORM.
> 
> Disregarding all the verbiage below, it sounds like Session.remove
> already does what I want: "[When Session.remove is called], the
> Session is thrown away, all of its transactional/connection resources
> are closed out, everything within it is explicitly gone."
> 
> So, if the underlying connection is closed at the end of every
> request, I don't actually need to do anything, right? I wouldn't even
> need to call `dispose` on the engine because all of its connections
> would already be closed.

no, the phrase "closed out" is probably confusing you, it means, "returned to 
the connection pool".  It is then up to the pool to decide if the connection is 
actually closed at that point.   I am averse to repeated reiteration of the 
presence of the connection pool throughout the documentation, and I've 
typically assumed the reader understands that "close == checked in", but it 
keeps coming up so I think I'll change all instances of "close" to be specific.


> 
> This raises a question: isn't the point of using a pool to avoid
> connecting to the database? Using `remove` seems like a brute force
> approach and that it might be better--in terms of the number of times
> we physically connect to the DB--to use `commit` or `rollback` as
> appropriate; but if I did that, I'd be back to needing to call
> dispose, etc.

using Session with a NullPool and regular autocommit=False means your app makes 
a database connection at the start of a request and closes it at the point of 
remove/close.   If you have an issue with connections remaining around, just 
use this configuration, it adds a tiny bit of overhead to each request, but 
generally your problem is solved.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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