On Jun 28, 2010, at 6:01 PM, jgarbers wrote:

> On Jun 25, 9:53 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
>> Beyond that, assuming you're using the ORM, and are ensuring that you fully 
>> exhaust any row-based result sets that you get from Session.execute(), all 
>> connections are returned to the pool explicitly without reliance on GC.
> 
> Michael, thanks very much for your helpful reply.  I'm not sure what
> you're suggesting by "fully exhaust any row-based result sets" here,
> though... are you saying that a connection will not be returned to the
> pool if I don't completely iterate through the result of a
> Session.execute()?

the thing returned from execute() is called a ResultProxy.  You have to call 
close() on it to release resources, unless the operation is an "autoclose" 
operation.   The conditions under which "autoclose" occurs are described at 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/connections.html?highlight=resultproxy#sqlalchemy.engine.base.ResultProxy.close
 .   "cursor.description is None" usually means, the statement was not a 
select() statement, meaning it returns no rows.

> 
> I just checked the code and it doesn't appear I'm using
> Session.execute() anyway, so are there other circumstances when an
> interrupted treatment of a result set could keep a connection from
> returning to the pool?

not really.   If you're using a Query object, it always closes result sets.

As I said before, if either of these two areas were the cause of your issue, 
you wouldn't see connections "leaking".  You'd get a very explicit, hard-stop, 
error message that the pool has reached its limit (well, unless you've 
configured your pool to be unbounded, which I'm assuming you haven't).   Its 
only if you are creating multiple pools, or are using connection.detach() which 
is quite unlikely, that you could potentially see connections being opened 
without a limit.   Note that if your application creates child forks, it would 
be creating an engine per process which could be part of the issue.



-- 
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