[mod_python] PSP Response

Graham Dumpleton grahamd at dscpl.com.au
Wed May 18 19:18:50 EDT 2005


The session object isn't created within this function. Are you able
to describe or post the handler/publisher which calls this function
and where the session is created? Bit hard to tell at this point with
out knowing what else is being done besides what is in this function.

Jeremy Kohansimeh wrote ..
> Hey Graham,
> 
> Thanks for your response. I made the following change to my code, but I
> am 
> still unable to prevent the page from hanging sometimes:
> 
> <code>
> def genGraphWAnnotsHTMLResponse( req, frames):
> """generates HTML response for request to graph"""
> 
> sess = req.sess
> seg_facade = sess.seg_facade
> 
> column_header, data = genSegmentAnnotsHTML( frames, sess.chrom_num, 
> seg_facade)
> 
> vars = { 'p_extend' : seg_facade.p_extend, \
> 'p_break' : seg_facade.p_break, \
> 'plot_image' : os.path.join( '../../images', sess.original_image), \
> 'session_id' : sess.id(), \
> 'cols' : column_header.__str__(), \
> 'data' : data.__str__() }
> 
> return psp.PSP( req, filename=ZOOM_WANNOTS_TMPL, vars=vars)
> </code>
> 
> I have made one other, possibly important, observation. The page will not
> hang the first time a session in created, but will subsequent times when
> it 
> is referenced. I can tell this, because if I get rid of the pysid cookie
> after a session has been created, which forces the creation of a new 
> session, the page works fine.
> 
> Do you have any suggestions? Thanks for your help.
> 
> Best Regards,
> Jeremy Kohansimeh
> 
> On 5/17/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> > 
> > 
> > Jeremy Kohansimeh wrote ..
> > > Hello,
> > >
> > > The following fragment of code will sometimes return a response and
> > other
> > > times just hang:
> > >
> > > <code>
> > > def genGraphWAnnotsHTMLResponse( req, frames):
> > > """generates HTML response for request to graph"""
> > >
> > > session = req.session
> > > seg_facade = session.seg_facade
> > >
> > > column_header, data = genSegmentAnnotsHTML( frames, session.chrom_num,
> > > seg_facade)
> > >
> > > vars = { 'p_extend' : seg_facade.p_extend, \
> > > 'p_break' : seg_facade.p_break, \
> > > 'plot_image' : os.path.join( '../../images', session.original_image),
> \
> > > 'session' : session.id(), \
> > > 'cols' : column_header.__str__(), \
> > > 'data' : data.__str__() }
> > >
> > > return psp.PSP( req, filename=ZOOM_WANNOTS_TMPL, vars=vars)
> > > </code>
> > >
> > > The path from the handler to here appears to be working fine. I did
> some
> > > debugging and can tell that the problem is somewhere in the psp.PSPcall.
> > > I
> > > think it may have something to do with the interpreter, but that is
> just
> > > a
> > > wild guess. Has anyone had similar issues?
> > 
> > One problem you can hit with this code, and for which there has
> > been a little discussion about over the last few days in the dev
> > area, is that the following code will hang if your PSP page tries
> > to reference the "session" object. The problem is that the PSP
> > class ignores the fact of whether or not you may have created
> > your own session object and will create its own if "session" is
> > referenced from the PSP page, with the session object it thus
> > creates being stored as "session" with the execution environment
> > of PSP so as to be accessible from your page.
> > 
> > Now you actually set "session" in your vars to the session ID
> > which if you try to access in the page will trigger the creation
> > of the second session object, although your session ID setting
> > will override PSPs attempt to set "session" to the session object
> > it creates. Either way, the attempt to create a second session
> > object for the same request can result in a deadlock.
> > 
> > I would suggest you try not using the "session" variable in
> > your vars, but use "my_session_id" for the session ID and if
> > you do need access to the session object you create in
> > PSP, set it as the "my_session" variable. Ie., avoid using
> > "session" name as that triggers the deadlock where you have
> > already created the session object.
> > 
> > The suggestion being dicussed in dev area is that the PSP
> > code check for the existance of "req.session" and if it
> > exists and PSP page tries to access "session", that session be set
> > to "req.session" rather than creating a new session object.
> > If this change were made for future version of mod_python,
> > you wouldn't need to set "session" in the vars as PSP will
> > do it automatically for you. In your page you could then say
> > "session.id()" to get the session ID.
> > 
> > Would this explain your problems and does avoiding using
> > "session" variable name in vars fix the problem?
> > 
> > Graham
> > 
> >


More information about the Mod_python mailing list