[Python-checkins] logging shutdown (was: Re: r61431 - python/trunk/Doc/library/logging.rst)

Vinay Sajip vinay_sajip at red-dove.com
Wed Mar 19 09:36:52 CET 2008


> I think (repeatedly) testing an app through IDLE is a reasonable use case.

I don't disagree, but cleanup of logging may not be all that trivial in some
scenarios: for example, if multiple threads have references to handlers,
then after shutdown() was called, logging by those threads would fail due to
I/O errors - a reasonable outcome. However, logging cannot know if threads
contain references to loggers or handlers, and so I do not e.g. remove
loggers on shutdown().

> Would it be reasonable for shutdown to remove logging from
> sys.modules, so that a rerun has some chance of succeeding via its own
> import?
>

I'm not sure that would be enough in the scenario I mentioned above - would
removing a module from sys.modules be a guarantee of removing it from
memory? If so, what if still-running threads contained references to loggers
etc. - wouldn't they potentially segfault?

It's safer, in my view, for the developer of an application to do cleanup of
their app if they want to test repeatedly in IDLE. After all, this could
involve cleanup of other resources which are nothing to do with logging; and
a developer can certainly remove handlers from loggers using the existing
API, after ensuring all their threads are done and there are no
unaccounted-for references to loggers and handlers.

Regards,

Vinay Sajip



More information about the Python-checkins mailing list