We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
GitHub fields:
assignee = None closed_at = None created_at = <Date 2022-02-15.08:36:55.743> labels = ['type-bug', 'library', '3.9'] title = 'QueueHandler logs stack_info twice' updated_at = <Date 2022-02-17.00:10:50.289> user = 'https://github.com/emontnemery'
bugs.python.org fields:
activity = <Date 2022-02-17.00:10:50.289> actor = 'ned.deily' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = <Date 2022-02-15.08:36:55.743> creator = 'erik.montnemery' dependencies = [] files = [] hgrepos = [] issue_num = 46755 keywords = ['patch'] message_count = 1.0 messages = ['413278'] nosy_count = 3.0 nosy_names = ['vinay.sajip', 'emontnemery', 'erik.montnemery'] pr_nums = ['31355'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue46755' versions = ['Python 3.9']
The text was updated successfully, but these errors were encountered:
logging.handlers.QueueHandler logs stack twice when stack_info=True:
>>> import logging >>> from logging.handlers import QueueHandler, QueueListener >>> from queue import Queue >>> q = Queue() >>> logging.getLogger().addHandler(QueueHandler(q)) >>> listener = QueueListener(q, logging.StreamHandler()) >>> listener.start() >>> _LOGGER.error("Hello", stack_info=True) Hello Stack (most recent call last): File "<stdin>", line 1, in <module> Stack (most recent call last): File "<stdin>", line 1, in <module>
Reproduced on CPython 3.9.9, but the code is unchanged in 3.10 and 3.11, so the issue should exist there too.
Patching QueueHandler.prepare() to set stack_info to None seems to fix this:
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index d42c48de5f..7cd5646d85 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1452,6 +1452,7 @@ def prepare(self, record): record.args = None record.exc_info = None record.exc_text = None + record.stack_info = None return record
def emit(self, record):
Related issue: bpo-34334, with patch #9537
Sorry, something went wrong.
The PR was merged and backported to 3.10 and 3.11.
No branches or pull requests
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: