mod_python: How to make a single object available to all instances?

Trond tamyk at online.no
Sun Jul 18 15:10:03 EDT 2004


It works, that is, the module is initiated once, but a copy of the
module is created for each thread..so it doesn't really solve my
memory problem. Maybe I've done something wrong, or maybe it just
isn't possible for 10 threads to use the same copy of the module?

Michael Ströder <michael at stroeder.com> wrote in message news:<jhmos1-pn1.ln1 at nb2.stroeder.com>...
> Robert Brewer wrote:
> > 
> > mod_python won't reload modules (as long as you keep *a* thread alive, I
> > think); therefore, you can put your dict in a module:
> > 
> > # myapp/env.py
> > 
> > bigdict = {}
> > 
> > On the first request to your app, start a new thread with a reference to
> > that module; subsequent imports will find env.py in sys.modules and
> > won't reload, and therefore won't reinit your bigdict.
> 
> Please enlighten me under which conditions this work.
> Does that also work with Apache 1.3 and worker processes? Or does it only 
> work with Apache 2.0 and threads?
> 
> Ciao, Michael.



More information about the Python-list mailing list