[mod_python] Child process init handler

Michael C. Neel neel at mediapulse.com
Tue Jan 27 17:28:26 EST 2004

sorry, hit some crtl combo and my email was sent early... :/

Mod_perl is able is so this somehow:

PerlChildInitHandler and PerlChildExitHandler do not refer to parts of
the request loop, they are to allow your modules to initialize data
structures and to clean up at the child process start-up and shutdown
respectively, for example by allocating and deallocating memory.

PerlInitHandler changes its behaviour depending upon where it is used.
In any case it is the first handler to be invoked in serving a request.
If found outside any <Location>, <Directory> or <Files> section (at the
top level), it is an alias for PerlPostReadRequestHandler. When inside
any such section it is an alias for PerlHeaderParserHandler.

So I think this could be used in a virual host setting, and be able to
get options in that scope.  Though it's been a while since I mod_perl'd

My C is rusty, but they might be pulling this from some combo of the
Apache Api functions:

static void modulename_child_init(server_rec *s, pool *p);

and maybe something in 
static void *modulename_create_server_config(pool *p, server_rec *s);
static void *modulename_merge_server_config(pool *p, void *server1_conf,
void *server2_conf);

...at work right now, but when I get home I'll browse source and abuse
my apache home box with my unstable C code =)


> -----Original Message-----
> From: Gregory (Grisha) Trubetskoy [mailto:grisha at modpython.org] 
> Sent: Tuesday, January 27, 2004 4:09 PM
> To: Michael C. Neel
> Cc: Mod_python at modpython.org
> Subject: Re: [mod_python] Child process init handler
> Apache doesn't really lend itself to this kind of thinking. I've never
> been able to clearly pinpoint what the problem is, but it 
> basically has to
> do with a lot of request parameters being generated on the 
> fly as a result
> of the combination of the particular's of the request and the apache
> configuration directives applicable to that request (which too are
> determined at runtime).
> Or, to put it another way - Apache's approach is "reactive" 
> rather than
> "proactive". When it parses its config it takes very little 
> action on the
> things it sees in it. Virtual servers just get piled into a 
> hash list, and
> only when a request for that particular server comes in is a 
> meaningful
> combination of a server and request object created. It's not like it
> "intializes" virtual servers at any point during start up, so 
> there is no
> "virtual server init" hook.
> In theory, when a child is spawned, mod_python could try to walk the
> config and try to make sense of it and create and call some sort of a
> per-server init hook, but that would more trouble than it's worth IMO.
> Grisha
> On Tue, 27 Jan 2004, Michael C. Neel wrote:
> > What I want to do:
> >
> > 	Run some initialization code when Apache spawns the child
> > process.  I do not want to call this handler for every 
> request, but I do
> > want to have access to the configuration, specifically PythonOptions
> >
> > In looking though the docs, I'm not sure PythonInitHandler 
> works this
> > way, and PythonImport may not be able to access the PythonOption
> > directives.  Is there something I'm overlooking?
> >
> > Mike
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >

More information about the Mod_python mailing list