Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Logging Handler.close does not remove instance from shutdown list. #129143

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

Closed
JTignor-Raltron opened this issue Jan 21, 2025 · 1 comment
Closed
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir

Comments

@JTignor-Raltron
Copy link

JTignor-Raltron commented Jan 21, 2025

Bug report

Bug description:

The close method on my custom handler was being called during shutdown despite me having closed it myself already. The close method (according to the documentation) is supposed to remove itself from the list to be called during shutdown. Took a look at it though and unforunately it doesn't actually do this as it's written.

The only thing it does is remove itself from the weak value dictionary _handlers which is just used to find handlers by name.

The collection that dictates what is used at shutdown (_handlerList) only gets the items removed if the weak reference is broken so close will be called as long as the handler hasn't been disposed of.

To make the docmentation accurate some new code needs to be implemented to loop though list and check the weak references against the current instance which would have the side benefit of tidying up any broken references. I guess could also leave it be and update the documentation for how it actually works, seems to have been this way for awhile and no one else seems to have issues. If it had been documented correctly could have worked around it as it is from the begining.

CPython versions tested on:

3.9

Operating systems tested on:

Windows

Linked PRs

@JTignor-Raltron JTignor-Raltron added the type-bug An unexpected behavior, bug, or error label Jan 21, 2025
@picnixz picnixz added the stdlib Python modules in the Lib dir label Jan 21, 2025
@vsajip
Copy link
Member

vsajip commented Jan 29, 2025

I agree with your second option - the documentation needs to be updated to correct the inaccuracy. The docstring is correct, so the ReST documentation should be consistent with that.

@vsajip vsajip added docs Documentation in the Doc dir and removed type-bug An unexpected behavior, bug, or error labels Feb 10, 2025
vsajip added a commit to vsajip/cpython that referenced this issue Feb 10, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 10, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 10, 2025
vsajip pushed a commit that referenced this issue Feb 10, 2025
vsajip pushed a commit that referenced this issue Feb 10, 2025
@vsajip vsajip closed this as completed Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir
Projects
Status: Todo
Development

No branches or pull requests

3 participants