[mod_python] Session problem

Graham Dumpleton grahamd at dscpl.com.au
Wed Nov 22 19:23:10 EST 2006


Jakub Labath wrote ..
> > > What I found weird is that the same mod_python request serviced two
> > > different clients at different times, but perhaps that makes sense
> for
> > > preforked apache.
> >
> > Just to clarify your terminology, it is the same mod_python *instance*
> > servicing 2 different client requests. And no, it is not weird, but
> > rather the whole point of mod_python. Well maybe not the *whole* point,
> > but a very important one. :) In the simplest case you get one python
> > interpreter per apache child process, thus avoiding the overhead of
> > creating a new interpreter for each request.
> 
> It was the same child process (that much makes sense too me too), but
> it also had the same address for modpython request object. Which I
> thought is little weird since if request comes from address A it
> should not be the same as if it comes from address B.
> But the python id is just a memory address so it is possible that it
> was just reusing the same memory space.

You could always print out:

  req.connection.id
  req.connection.remote_addr

It is possible that the connection ID might get reused, but if the remote
address is the same for both requests, then you would really worry.

> > A little light just went off in my head. Is it always *exactly* the same
> > session id being served up for *all* requests?
> 
> No 99% of the time all work works normally.
> User A comes along gets his own cookie user B comes along gets her own
> cookie ... and then in one moment user A gets the cookie that belongs
> to user B. While B user still gets her own cookie. Then user A notices
> that suddenly his username changed from Joe to Suzy and starts sending
> rather angry emails, which I cannot really blame him for.
> The problem seems to appear more often if the site is under heavier load.

Do both clients make requests to the server via any sort of proxy or otherwise
which could be caching pages? In your pages do you do anything to try and
manipulate how pages might be cached?

Graham


More information about the Mod_python mailing list