Ben
ben at medianstrip.net
Mon Mar 8 12:33:30 EST 2004
Hello, it seems like this is a question that is asked enough to be worth a) putting into the FAQ (for now), and b) eventually trying to solve. i used to do some apache API coding so i'd be willing to look into trying to support per-child (and possibly per-thread) initialization code. i remember this used to be possible, and looking at mod_perl i see it has a PerlChildExitHandler. http://perl.apache.org/docs/2.0/user/handlers/server.html i'll start code-diving today, and let people know what i find. (oh woe to the python programmer who has to read C!) take care, B ps i happen to want this for my project, which is an object / aspect oriented servlet framework, that supports mixin-style functionality for session-based authentication, caching, etc. i plan on releasing that too, after some bugfixes and documentation. > > Message: 2 > Date: Mon, 8 Mar 2004 00:13:03 -0600 > From: "Bert Hughes" <bert at tela.com> > Subject: Re: [mod_python] persistent, reliable globals > To: <mod_python at modpython.org> > Message-ID: <001701c404d4$6a73fa60$0301a8c0 at janine> > Content-Type: text/plain; charset="iso-8859-1" > > > ----- Original Message ----- > From: "David Geller" <dg at sponsera.com> > To: <mod_python at modpython.org> > Sent: Sunday, March 07, 2004 11:21 PM > Subject: [mod_python] persistent, reliable globals > > > > Hi, > > > > I would like to set a global variable (in memory) from a module. I would > > then like to access this same global variable susequently by other > > modules at any other time, and have the value that was set there to be > > there (until, of course, Apache is restarted). > > > > I have tried several ways of doing this, and it doesn't seem to be > > reliable - i.e., sometimes the global variable is set when I look at it, > > and sometimes it is still at its original state. > > > > What am I doing wrong (or right)? > > > > Thanks! > > > > > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > > > > > ------------------------------ > > Message: 3 > Date: Mon, 8 Mar 2004 00:45:47 -0600 > From: "Bert Hughes" <bert at tela.com> > Subject: Re: [mod_python] persistent, reliable globals > To: <mod_python at modpython.org> > Message-ID: <004f01c404d8$fd69c170$0301a8c0 at janine> > Content-Type: text/plain; charset="iso-8859-1" > > Apache starts number of child process - any given web connection could be > served by any of these, or apache root may start a new child to answer http > request. Refreshing same page from same client could result in service from > different apache child processes. Mod_python and your modules live in each > child independently - setting global only sets in it one apache process, not > other or future processes. > > At least that's my understanding. > > Bert Hughes > > ----- Original Message ----- > From: "David Geller" <dg at sponsera.com> > To: <mod_python at modpython.org> > Sent: Sunday, March 07, 2004 11:21 PM > Subject: [mod_python] persistent, reliable globals > > > > Hi, > > > > I would like to set a global variable (in memory) from a module. I would > > then like to access this same global variable susequently by other > > modules at any other time, and have the value that was set there to be > > there (until, of course, Apache is restarted). > > > > I have tried several ways of doing this, and it doesn't seem to be > > reliable - i.e., sometimes the global variable is set when I look at it, > > and sometimes it is still at its original state. > > > > What am I doing wrong (or right)? > > > > Thanks! > > > > > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > > > > > > ------------------------------ > > Message: 4 > Date: Mon, 8 Mar 2004 01:10:54 -0700 (MST) > From: Erik <mod_python at 24ksoftware.com> > Subject: Re: [mod_python] persistent, reliable globals > To: mod_python at modpython.org > Message-ID: > <Pine.LNX.4.58.0403080108300.14807 at ramuh.int.24ksoftware.com> > Content-Type: TEXT/PLAIN; charset=US-ASCII > > On Mon, 8 Mar 2004, David Geller wrote: > > > I would like to set a global variable (in memory) from a module. I would > > then like to access this same global variable susequently by other > > modules at any other time, and have the value that was set there to be > > there (until, of course, Apache is restarted). > > > > I have tried several ways of doing this, and it doesn't seem to be > > reliable - i.e., sometimes the global variable is set when I look at it, > > and sometimes it is still at its original state. > > > > What am I doing wrong (or right)? > > Greetings, > > New to the list and mod_python in general, but it sounds like you will > only be able to pull this off if you are using a threaded Apache. > Again, I'm new so I could be wrong. > > If you're stuck with a forked Apache, then you could try using > something from the IPC toolbox: shared files, shared memory, messages, > etc. I would pickle whatever you wanted shared to some temp file and > have your code check for that file and define it if does not exist. > That approach has some dangerous aspects to it. The threaded Apache > approach sounds much better. > > > Best regards, > Erik > > ------------------------------ > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > > > End of Mod_python Digest, Vol 12, Issue 10 > ****************************************** >
|