[mod_python] Session data

G . Sumner Hayes SumnerH at fool.com
Tue May 29 13:03:49 EST 2001

Gregory (Grisha) Trubetskoy <grisha at modpython.org> wrote:
> Since Apache 1.3 runs multiple processes, it is impossible to share memory
> between them and therefore maintain state in the server.

You can use either shared mmap or SysV shared mem (there are
python modules for both) to share memory.  I wound up writing
a Python shared dictionary (just pickles objects into the
filesystem when you set them, and unpickles them when you read
them) for my shared state, though I don't share user sessions--I
share things like parsed template files and other cacheable
server-side objects that require an expensive calculation the
first time they're read in.

Same idea would work for user sessions, and since it's in the
filesystem the kernel will take care of buffering for you and you
can use tools like "find" and "rm" to prune the cache. :-)

I agree with Grisha that you probably want to keep state on the
clients if you can, though.


rage, rage against the dying of the light

More information about the Mod_python mailing list