logging: don't attempt to close handlers unless they have been opened#727
logging: don't attempt to close handlers unless they have been opened#727blink1073 merged 3 commits intoipython:mainfrom
Conversation
* Accessing `Application.log.handlers` causes them to be opened if not done already. * Attempting to open log handlers whilst Python is shutting down causes traceback. * Closes ipython#722
for more information, see https://pre-commit.ci
|
This indeed fixes jupyter/notebook#6424 |
hroncok
left a comment
There was a problem hiding this comment.
I like the double-secured test very much!
|
However, the second part of the test fails for me in Fedora: |
Thanks for looking in, what version of Python were you using for your test? |
|
Sorry for not specifying. That'll be Python 3.10.4. Also: |
|
Note that I get the failure in traitlets 5.2.0 + this patch applied. If you think it's worth trying to use this branch entirely, I can do that, but there shouldn't be a difference. I've also tested with Python 3.11.0b1 (the same package versions as with 3.10.4) and there is the same failure. |
|
The same failure happens with Python 3.9.12 and: |
|
It seems to be a change in Python 3.10, that traceback doesn't show up any more. Not sure why, can't see anything obvious in the changes. Easy workaround... |
|
Note that if I remove the monkeypatch of logging.config.DictConfigurator.configure, I get the very same thing. Is it possible that it is never actually called? |
|
It's definitely called, but only when logging needs to be configured. This doesn't happen until the first time the log attribute is accessed. |
|
(With 83ac6f9 it should pass 3.7-3.10) |
hroncok
left a comment
There was a problem hiding this comment.
This passes now on Fedora with Pythons 3.9.12, 3.10.4, 3.11.0b1. Thank you.
|
Thanks! What's up with the 5.2.1.post0 release? It appears identical to 5.2.1 (sans the version information). |
|
I had a stray extra set of quotes in the version spec. |
|
Oh, I see. Thanks. |
Application.log.handlerscauses them to be opened if not done already.