[mod_python] Singleton Object

Tom Wells drshade at gmail.com
Thu Dec 13 02:58:07 EST 2007


Hi everyone,

I've been evaluating mod_python to implement a particular set of
requirements, and am now convinced that it is going to work for me, however
I have one remaining problem to solve:

I need to be able to spawn a single "watchdog" thread within my module which
connects back to a central server (via webservice calls) to provide
monitoring data, plus synchronize certain session data. I need to support
apache2.2 running in worker mpm (on linux platform), as well as winnt. In
the winnt deployment it's easy to spawn a single thread, as i can do this
the first time my module imports, but in worker mpm my module is imported
for each apache process started (I haven't actually tested the winnt side so
it's an assumption after some heavy reading up on the apache threading
models).

After some research with the C apache api I've noticed a hook called
"ap_hook_post_config" which seems like a good place to spawn singleton
objects, but I couldn't track this down in the mod_python hooks, nor have I
actually tried it with the C api, so I could be very wrong!

I've also taken a look at the mod_python Session bits, hoping to be able to
possibly set a global flag somewhere so that further module imports don't
spawn more threads, but I need something which is non-persistent (so if
apache restarts that cache is cleared, which I get from the MemorySession,
except I can't share this across processes, catch-22).

Anyways, any suggestions would be greatly appreciated!

Thanks,
Tom


-- 
http://www.tomwells.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20071213/cc195c39/attachment.html


More information about the Mod_python mailing list