Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

logging.handlers.MemoryHandler seems to be unconditionally flushed on process exit #95804

Closed
Assignees
vsajip
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@rascalking

Description

@rascalking

Bug report

The documentation forMemoryHandler claims:If flushOnClose is specified as False, then the buffer is not flushed when the handler is closed.

However, as this minimal test shows, it's not always respected. Running this snippet does print "this should not print to the console" to the console.

importlogging,logging.handlerslogging.root.addHandler(logging.handlers.MemoryHandler(capacity=10,flushLevel=logging.ERROR,target=logging.StreamHandler(),flushOnClose=False))logging.warning('this should not print to the console')

It looks like it's theshutdown handler inLib/logging/__init__.py that's doing the flushing.

If you explicitly close the handler before the process exits, you get the expected behavior...the log message isn't printed to the console. Which is why theunit test passes, that's what it's testing.

Your environment

I initially noticed this in python 3.8.13 on MacOS 12.5 (21G72). I can repro in the other python versions I have installed on that same macbook, 3.9.2 and 3.10.4.

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp