Graham Dumpleton
grahamd at dscpl.com.au
Sat Aug 6 00:13:06 EDT 2005
On 06/08/2005, at 1:47 PM, Scott Chapman wrote: > Graham Dumpleton wrote: >> On 06/08/2005, at 10:26 AM, Scott Chapman wrote: >>> Graham Dumpleton wrote: >>> >>>> BTW, almost have a working version of apache.register_cleanup() >>>> going anyway >>>> if you want to try it when I am done. Means modify mod_python >>>> source though. > > I downloaded svn, patched it and compiled it. Got a lot of warnings > about things being redefined but it's running fine so far. I need to > know what all parameters apache.register_cleanup() is expecting. Just like you had called req.register_cleanup() except that cleanup handler is called on server shutdown like req.server.register_cleanup(). register_cleanup(callable[, data]) Registers a cleanup. Argument callable can be any callable object, the optional argument data can be any object (default is None). At Apache child process termination, callable will be called with one argument, data. If errors are encountered during cleanup processing, they should be in error log. Note that I have actually made a minor mistake in the code. In apache.py, the prototype should be: def register_cleanup(handler,data=None): _apache.register_cleanup(_interpreter,_server,handler,data) I used "args=()" which isn't technically correct but only in as much as I used "()" instead of "None". I was thinking you could supply a tuple of arguments whereas you can actually only supply a single argument. What I did wouldn't have stopped it working though. Anyway, you should be able to do: def shutdown1(): apache.log_error("shutdown1") apache.register_cleanup(shutdown1) def shutdown2(data): apache.log_error("shutdown2 %r"%data) apache.register_cleanup(shutdown2,"data") Graham
|