[mod_python] Sending a message to Apache children

Svenne Krap svenne at krap.dk
Mon Nov 10 22:52:11 EST 2003


What about using shared memory/semaphores (shm on linux) ? I have used 
it successfully before (in PHP) for a similar case. It's blazing fast 
and allows you to have an invalidate-script outside). Each process 
simply aquires the semaphore (overkill, but truly safe) and then reads 
the "versionnumber" (or perhaps last change) from a shm-memory segment.

Oh, by the way. Out of bitter experience, don't "loose" the semaphore, 
always keep it accounted for....

By googleling, i found 
http://gigue.peabody.jhu.edu/~mdboom/omi/source/shm_source/shm.html

Svenne

Simon Willison wrote:

> Hi all,
>
> Is there a way of sending a "message" to all Apache children running a 
> mod_python application? Here's the problem: we have a template system 
> which compiles template strings in to an in-memory data structure. 
> This structure is cached in memory in a global dictionary for each 
> Apache child. At the moment templates are stored in the cache with a 
> timestamp saying when they were loaded, and expire and are reloaded 
> every 5 minutes. We want to be able to instantly invalidate a cached 
> template if an urgent change needs to be made to the site.
>
> Is there a way of pushing out a message to all of the Apache children 
> saying "reload template X NOW", without having to hit the file system 
> or database for every template request?
>
> Cheers,
>
> Simon Willison
>
> _______________________________________________
> 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