Skip to content
New issue

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

Make logging of exception which occurred on non main thread less verbose #16074

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

lukaszgo1
Copy link
Contributor

Link to issue number:

Fixes #16070

Summary of the issue:

To log unhandled exceptions NVDA relies on a custom except hook installed when initializing logging. Until Python 3.8 custom except hooks were not called for exception which occurred outside of the main thread - they were simply written to stderr (see python/cpython#42148). This worked well for NVDA, since it replaces stderr with a custom object which logs everything written to stderr, so the exceptions ended up in our log, just in a different way. In Python 3.8 it become possible to install a custom hook which gets called for exceptions which are raised in non main threads, but as part of this change the way in which they are handled by default has changed - the traceback is written to stderr line by line, rather than as a single call to print as it used to be. For NVDA it means that each line of the traceback results in a separate log entry making logging extremely noisy.

Description of user facing changes

Exception from threads different than the main one are logged in the same way as they were in NVDA 2023.3.

Description of development approach

A custom except hook for exception raised in threads was introduced. It logs them as an exception with additional information explaining in which thread they were raised.

Testing strategy:

Performed STR from #16070 - ensured that logging looks similarly to the one from 2023.3 and that single exception results in a single log entry.

Known issues with pull request:

None known

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@lukaszgo1 lukaszgo1 requested a review from a team as a code owner January 21, 2024 16:48
@lukaszgo1 lukaszgo1 requested review from seanbudd and removed request for a team January 21, 2024 16:48
Copy link
Collaborator

@CyrilleB79 CyrilleB79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix @lukaszgo1. Working well!

@seanbudd seanbudd added this to the 2024.1 milestone Jan 22, 2024
@seanbudd seanbudd merged commit 073e3fa into nvaccess:beta Jan 22, 2024
1 check passed
@lukaszgo1 lukaszgo1 deleted the I16070 branch January 22, 2024 10:33
Adriani90 pushed a commit to Adriani90/nvda that referenced this pull request Mar 13, 2024
…ose (nvaccess#16074)

Fixes nvaccess#16070

Summary of the issue:
To log unhandled exceptions NVDA relies on a custom except hook installed when initializing logging. Until Python 3.8 custom except hooks were not called for exception which occurred outside of the main thread - they were simply written to stderr (see python/cpython#42148). This worked well for NVDA, since it replaces stderr with a custom object which logs everything written to stderr, so the exceptions ended up in our log, just in a different way. In Python 3.8 it become possible to install a custom hook which gets called for exceptions which are raised in non main threads, but as part of this change the way in which they are handled by default has changed - the traceback is written to stderr line by line, rather than as a single call to print as it used to be. For NVDA it means that each line of the traceback results in a separate log entry making logging extremely noisy.

Description of user facing changes
Exception from threads different than the main one are logged in the same way as they were in NVDA 2023.3.

Description of development approach
A custom except hook for exception raised in threads was introduced. It logs them as an exception with additional information explaining in which thread they were raised.

Testing strategy:
Performed STR from nvaccess#16070 - ensured that logging looks similarly to the one from 2023.3 and that single exception results in a single log entry.

Known issues with p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants