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

Jim Jewett jimjjewett at gmail.com
Wed Mar 19 20:15:20 CET 2008


On 3/19/08, Vinay Sajip <vinay_sajip at red-dove.com> wrote:
> > I think (repeatedly) testing an app through IDLE is a reasonable use case.

> [other threads may still have references to loggers or handlers]

>  > 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?

No.  It will explicitly not be removed from memory while anything
holds a live reference.

Removing it from sys.modules just means that the next time a module
does "import logging", the logging initialization code will run again.

It is true that this could cause contention if the old version is
still holding an exclusive lock on some output file.

>  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.

Depending on the issue just fixed, the app may not have a clean shutdown.

-jJ


More information about the Python-Dev mailing list