OK. So does Session(bind=engine, expire_on_commit=False) usage always guarantee that engine and all other associated objects are cleared on doing a session.close() + engine.dispose().
On Friday, 11 January 2013 12:27:16 UTC+5:30, Michael Bayer wrote: > > the event mechanics issue applies to 0.7 and 0.8. while the engine will > be gc'ed in 0.8, the sessionmaker itself, if used, will still create an > anonymous subclass that is not cleared. creating many ad-hoc > sessionmaker() objects, while this was not its intended use, will cause > memory to grow. > > the patch at > http://www.sqlalchemy.org/trac/attachment/ticket/2650/2650.patch resolves. > > > > > On Jan 11, 2013, at 1:29 AM, Michael Bayer wrote: > > the sessionmaker() object is not GC-able in 0.7 right now due to event > mechanics. This issue does not exist in 0.8. I'll add a note. > > > > On Jan 11, 2013, at 1:18 AM, Michael Bayer wrote: > > there's some side effect occurring as a result of how 0.7 creates a new > subclass when using sessionmaker. Since you don't need a sessionmaker > here, please use this form: > > return Session(bind=engine, expire_on_commit=False) > > or upgrade to 0.8.0b2. > > > > On Jan 11, 2013, at 1:08 AM, Anoop K wrote: > > I tried the code in my setup.(SQLAlchemy-0.7.8-py2.6). Looks like engine > did not got GCed. > > *[anoop@localhost tmp]$ p engtest.py * > *about to delete sn...* > *about to gc.collect()...* > *Traceback (most recent call last):* > * File "engtest.py", line 31, in <module>* > * assert engine_is_removed* > *AssertionError* > > > > On Thursday, 10 January 2013 18:55:59 UTC+5:30, Anoop K wrote: >> >> It seems engine created using *create_engine* is not freed after cleanup >> of a session. Object graph indicates that event.listen for pool is holding >> reference to engine even after session is garbage collected. >> *What is the right way/api to delete an engine ?* >> >> *UseCase* >> As there are lot of databases in multiple boxes whose ip/user/password >> can change I would like to destroy *session and engine* after use. Cost >> of creating/closing connection can be ignored for my use case. >> >> >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sqlalchemy/-/RWBNo1sT1ogJ. > To post to this group, send email to sqlal...@googlegroups.com<javascript:> > . > To unsubscribe from this group, send email to > sqlalchemy+...@googlegroups.com <javascript:>. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlal...@googlegroups.com<javascript:> > . > To unsubscribe from this group, send email to > sqlalchemy+...@googlegroups.com <javascript:>. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlal...@googlegroups.com<javascript:> > . > To unsubscribe from this group, send email to > sqlalchemy+...@googlegroups.com <javascript:>. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/fAGeeGQfeRgJ. 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.