Skip to content

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

@JTignor-Raltron

Description

@JTignor-Raltron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directory

    Projects

    Status

    Done

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions