-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Ensure the gc module is available during interpreter exit #4166
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
Conversation
@@ -84,6 +84,7 @@ def destroy_fig(cls, fig): | |||
|
|||
@classmethod | |||
def destroy_all(cls): | |||
import gc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, this is only in this method since it also is registered as an atexit
function. Otherwise it wouldn't be necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it would also be worth adding a comment that this is here deliberately (since gc
is already imported at the module level any delinter is going to complain about this...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the # noqa
flag works on most linters?
Seems fine -- and pretty harmless in the 99.9% of non-corner cases where this is a non-issue. |
👍 from me modulo a comment / linter protection flag. |
Merged locally to add comment + linter flage |
@tacaswell Where did you merge locally? GitHub just shows that you merged my PR as-is. |
Or to be more specific, I'm wondering how you got GitHub to recognize this as merged, while also including your own changes. It would be lovely if I knew how to do that. |
Merged as 13a8f31 GH keeps track of 'mergestate' based on if the commits on the merge-branch are accessible from the target branch so all you have to do is merge locally and push to the target branch and GH is happy. |
This is directly related to #4165. Another side effect of
run_setup
is that any modules that are imported during therun_setup
call are later removed fromsys.modules
. If there are no other references to that module they will be garbage collected and any previous references to globals in that module will be replaced withNone
.Because
destroy_all
is registered as anatexit
function it will run even after all the module itself has been garbage collected (there are other contexts where this might happen as well). This seems to otherwise work since it was changed to aclassmethod
, so now theGcf
class itself is still hanging around. But it may be necessary to re-import thegc
module if it's to be made use of.