server wide variables

Discussion in 'Python' started by Jay Sonmez, Jun 25, 2007.

  1. Jay Sonmez

    Jay Sonmez Guest

    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?
    Jay Sonmez, Jun 25, 2007
    #1
    1. Advertising

  2. Stephen R Laniel, Jun 25, 2007
    #2
    1. Advertising

  3. Jay Sonmez

    Matimus Guest

    On Jun 25, 8:29 am, Jay Sonmez <> wrote:
    > 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?


    I don't have any experience with mod_python, but I'm assuming all of
    the standard python modules are available. You might check out
    http://docs.python.org/lib/module-shelve.html.
    Matimus, Jun 26, 2007
    #3
  4. On Jun 26, 1:29 am, Jay Sonmez <> wrote:
    > 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
    Graham Dumpleton, Jun 26, 2007
    #4
  5. On Jun 26, 10:29 am, Graham Dumpleton <>
    wrote:
    > On Jun 26, 1:29 am, Jay Sonmez <> wrote:
    >
    > > 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/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
    Graham Dumpleton, Jun 26, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Web Developer

    char 8bit wide or 7bit wide in c++?

    Web Developer, Jul 31, 2003, in forum: C++
    Replies:
    2
    Views:
    580
    John Harrison
    Jul 31, 2003
  2. pitthekid
    Replies:
    2
    Views:
    470
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 21, 2006
  3. Disc Magnet
    Replies:
    2
    Views:
    711
    Jukka K. Korpela
    May 15, 2010
  4. Disc Magnet
    Replies:
    2
    Views:
    787
    Neredbojias
    May 14, 2010
  5. Martin Rinehart

    80 columns wide? 132 columns wide?

    Martin Rinehart, Oct 31, 2008, in forum: Javascript
    Replies:
    16
    Views:
    176
    John W Kennedy
    Nov 13, 2008
Loading...

Share This Page