[issue10462] Handler.close is not called in subclass while Logger.removeHandler is called

R. David Murray report at bugs.python.org
Fri Nov 19 21:02:20 CET 2010


R. David Murray <rdmurray at bitdance.com> added the comment:

I doubt that close is ever called when removehandler is called.  That doesn't strike me as sensible semantics.  I suspect that what is happening is that in 2.6 calling removehandler removed all references to the handler, and python's garbage collection called the close method during cleanup.  In 2.7 something is probably still holding a reference; I know Vinay made a number of changes in how handlers are handled in 2.7/3.2.

I think Vinay will want to take a look since (assuming I am correct) the holding of the reference may be a bug, so I'm adding him to nosy.

However, you shouldn't depend on close getting called after the removehandler, since not all Python implementations do garbage collection/cleanup in the same way.  You should always explicitly call close when you are done with a resource.

Finally, I don't understand the point of your third example (but I haven't run it).

----------
nosy: +r.david.murray, vinay.sajip

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10462>
_______________________________________


More information about the Python-bugs-list mailing list