classification
Title: logging.handlers.QueueHandler acts unexpected
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jack__d, kai.jmueller, miss-islington, vinay.sajip
Priority: normal Keywords: patch

Created on 2021-06-21 13:04 by kai.jmueller, last changed 2021-07-28 10:46 by vinay.sajip. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27140 merged vinay.sajip, 2021-07-14 16:00
Messages (4)
msg396243 - (view) Author: Kai Müller (kai.jmueller) Date: 2021-06-21 13:04
According to the docstring of logging.handlers.QueueHandler
"The base implementation formats the record to merge the message and arguments, and removes unpickleable items from the record in-place."
But, if a just a log message is used w/o any arguments, the arguments are still set to None, which IMHO unexpected. Especially, according to the typeshed project, the "args" is ALWAYS either a dict or a tuple. But in this case, they are set to None which surprised my a lot.

Would it be possible to improve the docstring to state, that args, exc_info, exc_text are set to None and that msg is overwritten. If you miss this tiny but very important detail, additional handlers can act very wrong.
In addition, it seems to be that the type information needs to be improved in typeshed or are there any other plans on your side?
msg397504 - (view) Author: Jack DeVries (jack__d) * Date: 2021-07-14 18:39
I have another question about the docstring in the source beneath logging.handlers.QueueHandler.prepare. It says:

> The object returned by this method is enqueued.

But, the prepare method doesn't do the enqueuing operation, it just prepares the record and returns it back, so it seems like this statement is not accurate?
msg397518 - (view) Author: miss-islington (miss-islington) Date: 2021-07-15 00:06
New changeset 3b8075f9076490508567f0fb3dc689861544d1a8 by Vinay Sajip in branch 'main':
bpo-44473: Update docstring and documentation for QueueHandler.prepar… (GH-27140)
https://github.com/python/cpython/commit/3b8075f9076490508567f0fb3dc689861544d1a8
msg397540 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2021-07-15 11:28
> But, the prepare method doesn't do the enqueuing operation, it just prepares the record and returns it back, so it seems like this statement is not accurate?

It merely states what happens to the return value. It doesn't say it has already been enqueued. If you look at the entire documentation for the class (rather than just individual sentences) I don't think the way the class works is unclear.
History
Date User Action Args
2021-07-28 10:46:03vinay.sajipsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-07-15 11:28:59vinay.sajipsetmessages: + msg397540
2021-07-15 00:06:53miss-islingtonsetnosy: + miss-islington
messages: + msg397518
2021-07-14 18:39:43jack__dsetnosy: + jack__d
messages: + msg397504
2021-07-14 16:00:15vinay.sajipsetkeywords: + patch
stage: patch review
pull_requests: + pull_request25682
2021-07-04 10:11:27iritkatrielsetnosy: + vinay.sajip
2021-06-21 13:04:38kai.jmuellercreate