[mod_python] persistant variables

Gary Maynard maynard at mpi-cbg.de
Thu Mar 21 13:15:18 EST 2002

  I want to know how to store persistant variables in mod_python. I have
written some simple code that works like this:

def handler(req):
        global testthis
                d = testthis
                testthis = 1
        testthis = testthis + 1
        return apache.OK

each time the script is run it should print the last value of testthis and
then increment it.

However, because Apache has several servers running, I end up with several
instances of testhis, one of which gets printed and incremented each time.

How can I force mod_python to only have one instance of the variable? Or
should I be trying to do this in an entirely different way?

I can set Apache to only start with one server (which makes it work),
however it will spawn more servers if it gets two hits at the same time, so
this won't really work.


More information about the Mod_python mailing list