gh-150072: Optimize logging imports by lazily importing traceback#150073
Open
ByteFlowing1337 wants to merge 1 commit into
Open
gh-150072: Optimize logging imports by lazily importing traceback#150073ByteFlowing1337 wants to merge 1 commit into
traceback#150073ByteFlowing1337 wants to merge 1 commit into
Conversation
Member
|
Unfortunately the lazy import fails when trying to test logging during shutdown: ======================================================================
FAIL: test_logging_at_shutdown (test.test_logging.ModuleLevelMiscTest.test_logging_at_shutdown)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/runner/work/cpython/cpython/Lib/test/test_logging.py", line 5259, in test_logging_at_shutdown
self.assertIn("exception in __del__", err)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'exception in __del__' not found in '--- Logging error ---\nException ignored while calling deallocator <function A.__del__ at 0x20002d3e8d0>:\nTraceback (most recent call last):\n File "<string>", line 9, in __del__\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 2194, in exception\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 2186, in error\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1553, in error\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1669, in _log\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1685, in handle\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1741, in callHandlers\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1031, in handle\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1163, in emit\n File "/Users/runner/work/cpython/cpython/Lib/logging/__init__.py", line 1080, in handleError\nImportError: sys.meta_path is None, Python is likely shutting down\n' |
Contributor
Author
|
We can fix the test by adding |
Member
|
I would prefer that we do not overcomplicate atexit callbacks in this case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tracebackinlogging#150072