On Thursday 19 June 2008 21:49:33 Michael Bayer wrote:
> On Jun 18, 2008, at 6:43 PM, Arun Kumar PG wrote:
> > one more point that i forgot to mention in the workflow, so i re-
> > wrote it again:
> >
> > - search request comes
> > - if orm mapping is not created it's get created now (only
> > happens one time)
> > - new session is created using
> > orm.create_session(weak_identity_map=True). now this new session
> > is added to a python dict like this:
> >
> > resources = {
> >   SESSION: session
> >   OTHER_RESOURCE: obj
> > }
> >
> > and then this resources dict is attached to the current request
> > thread (this is done so that different DAOs can access the same
> > session and other resources from the current thread).
> > - all orm queries are fired.. results processed
> > - finally, current thread is accessed again and tear down happens
> > as below:
> >
> > resources = currentThread().resources
> > resources[SESSION].clear()
> > del resources
> >
> > my question is that i am deleting resources dict but not
> > resources[SESSION] (session object) which might be being pointed
> > to by sa data structure associated as a part of initial
> > orm.create_session call? i have not done a deep dive in sa source
> > code but just guessing.
>
> nothing strongly references the SA session within SQLA's
> implementation (unless you are using
> SessionContext/scoped_session). As I suggested earlier, if you
> suspect this Session is still hanging around, write some debugging
> code that searches in gc.get_objects() for it, after a gc.collect()
> has been called.
>
> I think it also might be worth it to look into standard SQLA usage
> patterns instead of the customized things you're doing, i.e.
> declare mappers within modules and not functions, use
> SessionContext, etc.

while on the theme, here a function from 
dbcook.tests.util.sa_gentestbase.py:

def memusage():
    import os
    pid = os.getpid()
    m = ''
    for l in file( '/proc/%(pid)s/status' % locals() ):
        l = l.strip()
        for k in 'VmPeak VmRSS VmData'.split():
            if l.startswith(k):
                m += '; '+l
    if m: print m

reduce the query to smaller results, repeat it 100 times and run above 
each time...

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