-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Namespaced loader cleanup #58630
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
Merged
Merged
Namespaced loader cleanup #58630
Conversation
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
re-run full all |
1 similar comment
re-run full all |
eb2c674
to
712837d
Compare
re-run full all |
1 similar comment
re-run full all |
d9575d5
to
a9c3ba7
Compare
270cc7e
to
f717519
Compare
This is done in two stages, first, the module instance in `sys.modules` is set to `None`. Then at a second stage, when creating a loader with the same namespace, it's actually removed from `sys.modules`. The reason for this two stage cleanup procedure is because this function might get called during the GC collection cycle and trigger https://bugs.python.org/issue40327 We seem to specially trigger this during the CI test runs with `coverage.py` tracking the code usage: Traceback (most recent call last): File "/urs/lib64/python3.6/site-packages/coverage/multiproc.py", line 37, in _bootstrap cov.start() File "/urs/lib64/python3.6/site-packages/coverage/control.py", line 527, in start self._init_for_start() File "/urs/lib64/python3.6/site-packages/coverage/control.py", line 455, in _init_for_start concurrency=concurrency, File "/urs/lib64/python3.6/site-packages/coverage/collector.py", line 111, in __init__ self.origin = short_stack() File "/urs/lib64/python3.6/site-packages/coverage/debug.py", line 157, in short_stack stack = inspect.stack()[limit:skip:-1] File "/usr/lib64/python3.6/inspect.py", line 1501, in stack return getouterframes(sys._getframe(1), context) File "/usr/lib64/python3.6/inspect.py", line 1478, in getouterframes frameinfo = (frame,) + getframeinfo(frame, context) File "/usr/lib64/python3.6/inspect.py", line 1452, in getframeinfo lines, lnum = findsource(frame) File "/usr/lib64/python3.6/inspect.py", line 780, in findsource module = getmodule(object, file) File "/usr/lib64/python3.6/inspect.py", line 732, in getmodule for modname, module in list(sys.modules.items()): RuntimeError: dictionary changed size during iteration
f717519
to
a6921d6
Compare
re-run full all |
Ch3LL
approved these changes
Oct 7, 2020
krionbsd
approved these changes
Oct 7, 2020
garethgreenaway
approved these changes
Oct 7, 2020
The pytest failures are expected at this stage. Will be fixed afterwards. Merging. |
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.
What does this PR do?
See title