On Jun 1, 2011, at 7:00 PM, Jon Nelson wrote:

> On Wed, Jun 1, 2011 at 4:47 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
>> metadata.reflect() would close() the connection used for reflection as it 
>> assumed it was passed an Engine, not a Connection, fixed in r926ee70b67ff.   
>> Nothing to do with begin_nested() or anything like that.
> 
> Why did this work in 0.6.[1,2,3,4,5,6,7] ?
> What's the "right" way to do this?


This is a brief summary of metadata.reflect() from 0.5-0.6 (was only introduced 
in 0.5)

def reflect(bind):
    conn = bind.connect()

    go_reflect_the_tables(conn)

Conspicuously missing is a corresponding close() of the connection.     In 0.7 
we got all 3000 something tests to pass on Pypy.  Pypy uses generational 
garbage collection, which  means it does not garbage collect anything until the 
GC runs periodically.   A half dozen tests against metadata.reflect() and the 
connection pool would freeze, as each test left a connection hanging open.  
We'd run out of connections.   

So here was the fix in 0.7:

def reflect(bind):
    conn = bind.connect()

    go_reflect_the_tables(conn)

   conn.close()

fixed !  Except it broke your app that happened to be passing a Connection, not 
an Engine (Connection has a connect() method too so "bind" can be either), and 
we closed your connection on you.  We had no tests for that.  Now we do.  Fixed 
again !


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