The recent discussion of max locks and deadlocking issues with _apache._global_(un)?lock() are timely for me:
I'm in the middle of writing a caching module for mod_python servlets so a developer can have the output of a servlet cached, keyed on the hash of the URI, for future requests. The goal, of course, is to increase throughput for dynamic pages with long shelf life (e.g., content manager updates database once per day, so the HTML only needs to be generated once per day, not per request). I need locking. My first gut instinct was to go to the fcntl module (lockf), but this is only available for unix. My second gut instinct was: so what? :-) Wanting a true x-platform tool I then thought of mod_python.Session needing locks, poked around the code, and saw how it uses _apache._global_lock(). Further poking around showed me how psp code caching uses the function. About the time I began worrying about deadlock issues I found the thread on this list discussing the same problems. The solution for Session and psp code caching is to explicitly use lock id 0. This works as long as a module does not hold the lock for the whole request, but unlocks immediately after acquiring the needed resource. Fine. So, my question: is this the recommended way for mod_python framework developers to acquire x-platform global locks? Explicitly use lock id 0? If so, is this a secret or should it be documented? Daniel Popowich ----------------------------------------------- http://home.comcast.net/~d.popowich/mpservlets/