[mod_python] mod_python.Session freezes with apache 2

Raphaël B. nashii at gmail.com
Thu Jan 21 19:36:06 EST 2010


Hello,

Thank you for your help.
After restarting apache, the problem was still here, so I've closed firefox
(I was very angry :D) and later, restarted it ... and ... it worked ... !

Have a good day, and thank you very much for your 'tips' !
Raphaël

Le 21 janvier 2010 05:42, Graham Dumpleton <graham.dumpleton at gmail.com> a
écrit :

> 2010/1/21 Raphaël B. <nashii at gmail.com>:
> > Hello,
> >
> > I'm attempting to create some web application with mod_python, but as
> soon
> > as I call one attribute/method that is linked to the session module, the
> > navigator is "freezing" (not exactly, in fact, it is searching the
> webpage,
> > and searching, and searching ...)
> >
> > I'm working with mod_python.psp in apache, but I have tried with
> > mod_python.publisher too, and neither is working ...
> >
> > psp: there is just that in the page:
> >
> > <%
> > if not hasattr(req,'session'):
> >     req.session = Session.Session(req)
>
> The session object is already created for you by PSP so these lines
> should not be needed.
>
> > if req.session.is_new():
> >     req.write("Hello !")
> > %>
>
> You should though from memory only be accessing session object as
> 'session' and not 'req.session'. This is because PSP will look for the
> fact that 'session' is used and use that as a basis of creating it for
> you.
>
> It is possible that the way you are doing this is deadlocking the
> request on itself as you can't have one request create two session
> objects.
>
> Once it is deadlocked like that, even if you close the browser it says
> deadlocked and so further requests will also be locked out.
>
> Thus, fix the code, restart Apache to get rid of deadlock and start over.
>
> > and publisher:
> >
> > #!/usr/bin/python
>
> You don't need the above line.
>
> > # -*- coding: iso-8859-1 -*-
> >
> > import sys
> > from mod_python import apache, util, Session
> >
> > def index(req):
> >     req.content_type = "text/plain; charset=iso-8859-1"
> >     req.send_http_header()
> >     req.write("Hello world!\n")
> >     sess = Session.Session(req)
>
> As a guideline, always save session as 'req.session'. Further, if
> needing to create/access sessions in sub functions, always a good idea
> to use the pattern:
>
>  def function(req):
>     if not hasattr(req, 'session'):
>      req.session = Session.Session(req)
>
> If you don't do this, you risk deadlocking on yourself again.
>
> Graham
>
> >     return "Bye bye!"
> >
> > Both are freezing.
> >
> > I think my head will explode if it continue ><
> >
> > Could you please help me ? Perhaps apache is misconfigured for mod_python
> ?
> > Could you give me some way to correct the problem ?
> >
> > Thank you very much,
> > Raphaël
> >
> > PS: Excuse me for my english, i'm French.
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20100122/f646abfd/attachment.html


More information about the Mod_python mailing list