This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author socketpair
Recipients socketpair
Date 2011-04-28.19:29:15
SpamBayes Score 3.2246744e-10
Marked as misclassified No
Message-id <1304018959.77.0.656415451022.issue11950@psf.upfronthosting.co.za>
In-reply-to
Content
logger use dict for loggers instead of WeakValueDictionary

Now, when object returned by getLogger() gets unreferenced - it will not be garbage collected, as reference is stored in logging module. This will results in leaked file object, that cannot be closed in easy way. Some modules (notable yum) opens dozen of loggers that prevents me to unmount directory where logs placed. Now, I use workaround:

-----------------------
try:
    # work with yum
finally:
    yum_base_cli.close()
    yum_base_cli.closeRpmDB()
    yum_base_cli.doUnlock()
    del yum_base_cli
    # gc.collect() may be called here, but it does not actually change anything....
    for logger_name,logger in cli.logging.Logger.manager.loggerDict.iteritems():
        if not logger_name.startswith('yum'):
            continue
        for h in logger.handlers:
            h.flush()
            h.close()
-----------------------
The problem in that logging module stores many references in lists and dicts. So just replacing {} with WeakValueDictionary() 
does not eliminate problem fully.

I have checked, problem exists in all python versions
History
Date User Action Args
2011-04-28 19:29:19socketpairsetrecipients: + socketpair
2011-04-28 19:29:19socketpairsetmessageid: <1304018959.77.0.656415451022.issue11950@psf.upfronthosting.co.za>
2011-04-28 19:29:16socketpairlinkissue11950 messages
2011-04-28 19:29:15socketpaircreate