This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: QueueHandler formatting affects other handlers
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David Ruggles, Manjusaka, ned.deily, vinay.sajip, xtreak
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-12 13:55 by David Ruggles, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
queuehandler_bug.py David Ruggles, 2019-01-12 13:55 Example of issue
Pull Requests
URL Status Linked Edit
PR 11537 merged Manjusaka, 2019-01-12 17:37
PR 11659 merged xtreak, 2019-01-23 13:15
PR 12714 closed miss-islington, 2019-04-07 07:52
PR 12716 merged xtreak, 2019-04-07 15:23
PR 13061 merged miss-islington, 2019-05-02 17:05
Messages (9)
msg333526 - (view) Author: David Ruggles (David Ruggles) Date: 2019-01-12 13:55
ISSUE: if you add a formatter to QueueHandler any subsequently added handlers will get the formatting added to QueueHandler

CAUSE: as best as I can tell, the code here:
https://github.com/python/cpython/blob/d586ccb04f79863c819b212ec5b9d873964078e4/Lib/logging/handlers.py#L1380
is modifying the record object so when it get passed to the next handler here:
https://github.com/python/cpython/blob/d586ccb04f79863c819b212ec5b9d873964078e4/Lib/logging/__init__.py#L1656
it includes the formatting applied by the QueueHandler's formatter.

I worked around this issue by moving my formatter from the QueueHandler to the QueueListener

I've attached a simple example of the issue

NOTE: I marked this as Python 3.7 because that's what I'm using, but I looked at github and the code is in master so I assume this affects 3.8 too.
msg333530 - (view) Author: Manjusaka (Manjusaka) * Date: 2019-01-12 17:39
I have already work on a PR for it
msg333534 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-01-12 23:32
Any idea why the same PR appears three times in the PR list? Is it because for some reason you've added the issue link multiple times in the PR, when it's not needed?
msg333535 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-01-12 23:39
@vinay.sajip It's known issue discussed here https://github.com/python/bugs.python.org/issues/12
msg334248 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-01-23 07:08
New changeset da6424e96ada72c15c91bddb0a411acf7119e10a by Vinay Sajip (Manjusaka) in branch 'master':
bpo-35726: Prevented QueueHandler formatting from affecting other handlers (GH-11537)
https://github.com/python/cpython/commit/da6424e96ada72c15c91bddb0a411acf7119e10a
msg334249 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-01-23 07:10
Merged for 3.8, will add backport labels to PR in due course.
msg339559 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-04-07 07:51
New changeset 2dad96013ca24abdc5ba5a369ea42d70ff02487a by Vinay Sajip (Xtreak) in branch 'master':
bpo-35726: Add test for QueueHandler with multiple handlers (GH-11659)
https://github.com/python/cpython/commit/2dad96013ca24abdc5ba5a369ea42d70ff02487a
msg341287 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-05-02 17:02
New changeset 386b6f07a9703746590a5f29281b93c931c0e6d3 by Ned Deily (Xtreak) in branch '3.7':
[3.7] bpo-35726: Prevented QueueHandler formatting from affecting other handlers (GH-11537) (GH-12716)
https://github.com/python/cpython/commit/386b6f07a9703746590a5f29281b93c931c0e6d3
msg341288 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-05-02 17:24
New changeset 3f8f64ebf3ab05038ed0b5a4adc83d0a5e9fbb82 by Ned Deily (Miss Islington (bot)) in branch '3.7':
bpo-35726: Add test for QueueHandler with multiple handlers (GH-11659) (GH-13061)
https://github.com/python/cpython/commit/3f8f64ebf3ab05038ed0b5a4adc83d0a5e9fbb82
History
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 79907
2019-05-02 17:25:02ned.deilysetkeywords: patch, patch, patch
status: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8
2019-05-02 17:24:05ned.deilysetmessages: + msg341288
2019-05-02 17:05:45miss-islingtonsetpull_requests: + pull_request12978
2019-05-02 17:02:47ned.deilysetnosy: + ned.deily
messages: + msg341287
2019-04-07 15:23:48xtreaksetpull_requests: + pull_request12641
2019-04-07 07:52:00miss-islingtonsetpull_requests: + pull_request12639
2019-04-07 07:51:40vinay.sajipsetmessages: + msg339559
2019-04-07 07:48:19vinay.sajipsetpull_requests: - pull_request11458
2019-04-07 07:48:12vinay.sajipsetpull_requests: - pull_request11459
2019-04-07 07:48:06vinay.sajipsetpull_requests: - pull_request11460
2019-01-23 13:15:41xtreaksetpull_requests: + pull_request11460
2019-01-23 13:15:34xtreaksetpull_requests: + pull_request11459
2019-01-23 13:15:26xtreaksetpull_requests: + pull_request11458
2019-01-23 13:15:17xtreaksetpull_requests: + pull_request11457
2019-01-23 07:10:58vinay.sajipsetkeywords: patch, patch, patch

messages: + msg334249
title: QueueHandler formating affects other handlers -> QueueHandler formatting affects other handlers
2019-01-23 07:08:41vinay.sajipsetmessages: + msg334248
2019-01-13 01:01:15Manjusakasetpull_requests: - pull_request11141
2019-01-13 01:00:59Manjusakasetpull_requests: - pull_request11140
2019-01-12 23:39:41xtreaksetkeywords: patch, patch, patch
nosy: + xtreak
messages: + msg333535

2019-01-12 23:32:40vinay.sajipsetkeywords: patch, patch, patch

messages: + msg333534
2019-01-12 17:39:54Manjusakasetnosy: + Manjusaka
messages: + msg333530
2019-01-12 17:37:23Manjusakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request11142
2019-01-12 17:37:18Manjusakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11141
2019-01-12 17:37:12Manjusakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11140
2019-01-12 15:09:12xtreaksetnosy: + vinay.sajip
2019-01-12 13:55:13David Rugglescreate