Repository navigation
Defer hooks registered while watched modules are initializing #367
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
Draft
Rutvik552k
wants to merge
2
commits into
GrahamDumpleton:develop
Choose a base branch
from
Rutvik552k:fix/defer-hooks-during-import-366
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−5
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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.
Probably, just
name in _post_import_hooksis enough here, sincenotify_module_loaded(), as you mentioned in your comment, removes the list of hooks once notification starts (which, by the way, for some reason contradicts the first comment in the module…).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 checked the queue-only condition against a loaded-module case: register a pending hook, then insert an already initialized
types.ModuleTypeintosys.modules, and register another hook. Both the original implementation and this patch run the new hook immediately; checking only queue membership leaves it queued. I retained the initialization guard to preserve that existing behavior and addedtest_loaded_module_with_pending_hook_runs_new_hook_immediately.You are right about the introductory comment: I corrected it to describe removing the entry before notification. This follow-up changes only that comment and the regression test. The hook test file passes (12 tests), and the new test also passes with extensions disabled (1 passed, 11 deselected). The latter run printed an ignored pyreadline3 console-destructor warning at interpreter shutdown; no baseline comparison or pre-existing-warning claim is made. The previously recorded broader results are reused because the runtime implementation is unchanged; the full version matrix remains unrun.
This assessment and follow-up used AI assistance; no human review is claimed.
Uh oh!
There was an error while loading. Please reload this page.
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.
But is this behavior really worth preserving? With it, the old hook is never fired! If the new hook is left in the queue, the firing order will not be violated, and the user is also more likely to notice that something went wrong.