mod_python: How to make a single object available to allinstances?
Trond A Myklebust
tamyk at online.no
Mon Jul 19 04:34:08 EDT 2004
I am using Apache 1. The bigdict isn't reinitiated, but each thread gets
a copy of the object, I wanted if possible to have one copy of the
object for all threads to use, but suppose it may not be possible.
Is mod_python freeing up completely the memory used for each thread when
it is finished serving a user?
--
Trond A Myklebust
IT - UDS
European Organisation for Nuclear Research
CERN Tel: +41 22 76 73833
CH-1211 Geneva 23 Mob: +47 99 50 19 82
On Sun, 2004-07-18 at 22:19, Robert Brewer wrote:
> Michael Ströder wrote:
> > 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?
>
> I'm not an expert on Apache or mod_python by any means. The above technique works on Apache 2 on my Win2k box. Y'all should probably ask Grisha on the mod_python list...
>
> Trond, are you using Apache 1 or 2?
>
>
> Robert Brewer
> MIS
> Amor Ministries
> fumanchu at amor.org
>
More information about the Python-list
mailing list