Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment: > In general it would be nice if logging were more conservative (or
> cautious) when it comes to keeping objects persistent. It is too easy to > fall into a trap and experience memory leaks. I've checked in a change into trunk today which might improve matters. Handler.__init__ no longer adds the handler instance to the _handlers map unconditionally, but still adds it to the _handlerList array. The only place this array is actually used is in the shutdown() API, which is registered to be run via atexit. It flushes and closes all the handlers in the list, so that any data in logging buffers gets flushed before the process exits. The _handlers dict is now used to hold a mapping between handler names and handlers - the name property was added to Handler in the change I checked in today. This will be used by the dictConfig functionality which is proposed in PEP 391. If no name property is set on a Handler, then this will not add any additional references to handlers. Python 2.7a0 (trunk:75403, Oct 14 2009, 20:14:09) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import logging [49139 refs] >>> logging._handlerList [] [49146 refs] >>> logging.Handler() <logging.Handler object at 0x00B72658> [49179 refs] >>> logging.Handler() <logging.Handler object at 0x00B72620> [49202 refs] >>> logging.Handler() <logging.Handler object at 0x00B764D0> [49225 refs] >>> logging._handlerList [<logging.Handler object at 0x00B764D0>, <logging.Handler object at 0x00B72620>, <logging.Handler object at 0x00B72658>] [49225 refs] >>> logging.shutdown() [49156 refs] >>> logging._handlerList [] [49156 refs] >>> ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6615> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com