`logging.shutdown()` should clear `logging._handlerList` if that's what it's called with
Nobody has claimed this yet.
- #129681 by @cjw296 — closed without merging
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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 their flush() and close() 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 processing logging._handlerList, it should clear that list once it finished to prevent handlers having their flush() and close() methods called more than once.
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux, macOS
Linked PRs
- gh-129681
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the logging.shutdown() entry point and inspect how it processes logging._handlerList, including the repeated flush() and close() calls described in the report. Confirm that shutdown clears the default handler list after processing it, and verify that repeated shutdown calls do not process the same handlers again.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100