On Jul 4, 2008, at 4:52 AM, Henk wrote:

>
> Hi,
>
> I notice that the ResultProxy class has no __del__ method.
>
> I am using the sql expression language directly with using the
> 'execute' method on a select that is bound to an engine with a
> QueuePool.
> The problem is that if I forget to explicitly close the ResultProxy
> that is returned from the execute method, the connection associated
> with the ResultProxy will never be released back to the pool.
> Is this by design? or could the ResultProxy be modified to include a
> __del__ method that calls the close method when the ResultProxy goes
> out of scope?.
> The SQLAchemy documentation for 0.3 explicitly mentions that
> ResultProxy will autoclose when it is gc'd. but later docs do not...

ResultProxy does not need a __del__ since the underlying cursor and  
connection it references are automatically closed out (in the case of  
the Connection, returned to the connection pool) when garbage  
collected.    The pool mechanism to accomplish this in 0.3 is in fact  
a __del__ method on ConnectionFairy but 0.4 and above don't use  
__del__ since it can be problematic (preventing circular GC cleanup,  
and providing an undefined state within the body of __del__); they  
instead use a weakref callback.

Additionally, in 0.4 and above the ResultProxy is *explicitly* closed  
out, no reliance on GC needed, in almost all cases except when a  
ResultProxy with pending results is discarded.  This means any insert/ 
udpdate/delete operation, or a select where you call fetchall() or  
otherwise exhaust all the results, is closed immediately.   Migrating  
to at least version 0.4 is strongly urged in any case.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to