quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick <n...@dd.revealed.net>
Subject Re: glue between apache and python logging
Date Thu, 20 Oct 2005 20:52:51 GMT
Jim Gallacher wrote:
> Beyond that it still segfaults for me. The other problem is that you are 
> not removing the handler instance from the logging instance so you still 
> have a memory leak. 100k requests would result in 100k handler 
> instances. Oh, and there might be a bit of a performance issue when 
> emit() gets fired 100k times. ;) Or should I assume that the user will 
> still be required to include req.register_cleanup(log.removeHandler, 
> hdlr) in their code?

Not sure if this will help, but in my implementation I registered my hander
on the root logger as global code in the handler module, not for each
request.  In that case I used a threading.local to keep track of req, which
I had to register and free for each request of course.  I couldn't get
around the minimal bookkeeping required of registering the req object on
each request, though like Nic's code, I registered a cleanup in a closure to
handle the freeing.

Alternatively, you can register the server and use apache.log_error with a
server object, which should not leak.  Also, if you don't care about logging
to a particular server, you can, of course, just call apache.log_error
without a server argument.

Nick


Mime
View raw message