server wide variables

J

Jay Sonmez

I want to be able to save some server variables as long as Apache runs
on the server (mod_python).

How is that possible in Python?
 
G

Graham Dumpleton

I want to be able to save some server variables as long as Apache runs
on the server (mod_python).

How is that possible in Python?

It depends on whether you expect all Apache child processes for that
server to be able to access the data and for the data to be able to
survive the killing off and start up of individual Apache child
processes.

For background on some of the issues read:

http://www.dscpl.com.au/wiki/ModPython/Articles/TheProcessInterpreterModel

Saving data in os.environ is not recommended even if they have to
survive just within the context of that specific interpreter within
that process, as os.environ access and update is not thread protected
and Apache child processes may be multithreaded.

So, read that referenced document and then perhaps explain you
expectations a bit better.

Graham
 
G

Graham Dumpleton

It depends on whether you expect all Apache child processes for that
server to be able to access the data and for the data to be able to
survive the killing off and start up of individual Apache child
processes.

For background on some of the issues read:

http://www.dscpl.com.au/wiki/ModPython/Articles/TheProcessInterpreter...

Saving data in os.environ is not recommended even if they have to
survive just within the context of that specific interpreter within
that process, as os.environ access and update is not thread protected
and Apache child processes may be multithreaded.

Before someone decides to shoot me down, yes I know that dictionaries
themselves are thread safe and thus os.environ itself is thread safe.
In making that comment I am looking more at the higher level locking
aspects of a combined set of data, ie., the same as you might have for
global data in a module and what is required to protect that in the
presence of multiple threads. The os.environ dictionary being what it
is, people may not appreciate the need that locking may still be
required if one is going to use it as a means of holding data that can
change over time. In short, os.environ simply shouldn't be used for
that anyway.

Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top