[mod_python] Sending a message to Apache children

perry.tew at cibavision.novartis.com perry.tew at cibavision.novartis.com
Tue Nov 11 08:27:40 EST 2003

Something I've found useful is to use the CleanupHandler to handle this 
kind of thing.  I have a security realm that caches users, roles, and 
protected urls.  I have a cleanup handler that detects changes in the 
database and updates the cache.  Since this happens after the request has 
ended, there is no impact to the user.  Each child is updated after each 
one handles a request.  The only downside is that a single request must be 
served before the change is placed into effect.  However, given the number 
of requests my handlers serve, that's a very small issue compared to 
adding the overhead of checking for changes during every single request 
while the browser is waiting.

Just some thoughts,

On Nov 10, 2003, at 11:16 AM, 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?

Do you check the timestamp on the template from the filesystem?  That 
might be better than to just throw away the template every 5 minutes. 
I can assume that most templates will be static for longer than 5 


Mod_python mailing list
Mod_python at modpython.org

More information about the Mod_python mailing list