On Aug 24, 2011, at 10:04 AM, limodou wrote: > > finally I found the problem. In my case I build my own ORM based on > sqlalchemy, I call it "uliorm". And it only use base select, update, > insert, delete statements. And in order to keep the whole process can > share the same connection object, I used the > engin.contextual_connect() to get the default connection, and my logic > same like this: > > db = create_engine(xxx, pool_recycle=7200) > conn = db.contextual_connect() > db.begin() > try: > try: > db.execute(yyyy) > db.commit() > except: > db.rollback() > finally: > conn.close() > > But it seems that the conn is not close correctly, so the pool will > not recycle it.
That has to be a "threadlocal" engine, based on the "begin()/rollback/commit" methods available, so the connection stays open until close() is called on db as well. db.closed will tell you if its closed. -- 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.