-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging.shutdown()
should clear logging._handlerList
if that's what it's called with
#129268
Comments
Would you like to submit a PR? |
Would be good to get a second opinion as to why this is the way it is. @vsajip - you around on here? |
Well, the API documentation for
So, calling
The Since the case you mention involves calling If the handlers throw some other stdlib exception than |
@vsajip - what reason could there be to not |
Similar but not a duplicate: #129143 |
Don't know yet if there is one, but I'm generally not keen on making changes to cover for what might be bad practice in user code. I gave some specific reasons why I thought there might be bad practice, but those haven't been addressed. As for #129143 - it just looks like a documentation inaccuracy, as the docstring matches the behaviour of the code. |
Bug report
Bug description:
In the wild, I've encountered situations where
logging.shutdown
gets called more than once in a process.The current implementation is called with
logging._handlerList
by default, meaning that handlers can have theirflush()
andclose()
methods called more than once, which can cause bad things to happen if those handlers are not amenable to being closed more than once.If
logging.shutdown()
is processinglogging._handlerList
, it should clear that list once it finished to prevent handlers having theirflush()
andclose()
methods called more than once.CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux, macOS
The text was updated successfully, but these errors were encountered: