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

Created on 2019-01-12 13:55 by David Ruggles, last changed 2019-01-23 13:15 by xtreak.

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 open xtreak, 2019-01-23 13:15
PR 11659 open xtreak, 2019-01-23 13:15
PR 11659 open xtreak, 2019-01-23 13:15
PR 11659 open xtreak, 2019-01-23 13:15
Messages (6)
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 triager) 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.
History
Date User Action Args
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