classification
Title: Logging libraries BufferingHandler flushed twice at shutdown
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: adamist521, iritkatriel, vinay.sajip
Priority: normal Keywords:

Created on 2020-07-29 05:57 by adamist521, last changed 2021-01-11 17:00 by iritkatriel. This issue is now closed.

Messages (5)
msg374559 - (view) Author: Tatsunosuke Shimada (adamist521) Date: 2020-07-29 05:57
BufferingHandler

I expected function flush of BufferingHandler called once but it is called twice. 
This is due to that shutdown calls flush before close function which calls flush function inside.
(Faced this issue on my custom implementation of flush function.)

Seems that there is no need of calling flush inside BufferingHandler.

Following is the link to the code of function shutdown and Buffering Handler
https://github.com/python/cpython/blob/0124f2b5e0f88ee7f5d40fca96dbf087cbe4764b/Lib/logging/handlers.py#L1286
https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Lib/logging/__init__.py#L2151

This issue could be also related.
https://bugs.python.org/issue26559
msg374560 - (view) Author: Tatsunosuke Shimada (adamist521) Date: 2020-07-29 06:07
Found related issue.
https://bugs.python.org/issue901330
msg375012 - (view) Author: Irit Katriel (iritkatriel) * (Python triager) Date: 2020-08-07 16:31
I think this may be the same issue as in:

https://stackoverflow.com/questions/47549602/logging-handlers-bufferinghandler-subclassed-handler-showing-log-twice

Did you call flush on super()?

If this is not the same issue, please post a code snippet to explain what exactly you are seeing.
msg379039 - (view) Author: Irit Katriel (iritkatriel) * (Python triager) Date: 2020-10-19 22:23
adamist521, is your issue resolved by now? Does calling flush() on super help?

If not, can you please provide a script demonstrating the problem?
msg384849 - (view) Author: Irit Katriel (iritkatriel) * (Python triager) Date: 2021-01-11 17:00
I'm assuming the link solved your issue. If you are still having a problem please create a new issue, and include a code snippet to show what you are doing exactly.
History
Date User Action Args
2021-01-11 17:00:10iritkatrielsetstatus: open -> closed
resolution: not a bug
messages: + msg384849

stage: resolved
2020-10-19 22:23:14iritkatrielsetmessages: + msg379039
2020-08-07 16:31:49iritkatrielsetnosy: + iritkatriel
messages: + msg375012
2020-07-29 06:07:05adamist521setmessages: + msg374560
2020-07-29 05:57:24adamist521create