logging module: removing handlers
Michele Simionato
michele.simionato at gmail.com
Wed Nov 21 04:06:13 EST 2007
I have just discovered a bug in my code using the logging module, due
to
handlers not being closed properly. The issue was that I called the
function
removeHandler and I assumed that it took care of closing the handler,
but it did not.
Looking at the source code of logging/__init__.py I discovered that it
is
implemented as follows:
def removeHandler(self, hdlr):
"""
Remove the specified handler from this logger.
"""
if hdlr in self.handlers:
#hdlr.close()
hdlr.acquire()
try:
self.handlers.remove(hdlr)
finally:
hdlr.release()
The question is: why in the hell the "hdlr.close()" line is
commented??
I discovered this because we had locks in our production database
(we were logging on the DB) and it was not easy to spot the source of
the problem, so I would like to know the rationale for not closing
the handler in removeHandler.
Michele Simionato
More information about the Python-list
mailing list