-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix two multiprocessing issues #10642
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
pylint/lint/pylinter.py
Outdated
self._registered_checkers: set[tuple[str, checkers.BaseChecker]] = set() | ||
"""Set of tuples with loaded checker names and reference to checker.""" | ||
self._registered_dynamic_plugin_checkers: set[ | ||
tuple[str, checkers.BaseChecker] | ||
] = set() |
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.
Even though these get pickled, they shouldn't increase the linter object size too much as the checkers are already included in self._checkers
.
pylint/lint/pylinter.py
Outdated
if hasattr(checker, "msgs"): | ||
self.msgs_store.deregister_messages_from_checker(checker) |
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.
Not sure if it's really necessary to reregister all messages here. The code works fine even if we don't as the re-register just overwrites it with the same info. (The code only fails if it doesn't match).
In contrast to self._checkers
or the reports, the message store doesn't save a reference to the checker itself.
I've included it here for completeness but it would simplify the logic a bit if don't do it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10642 +/- ##
=======================================
Coverage 95.96% 95.96%
=======================================
Files 176 176
Lines 19502 19521 +19
=======================================
+ Hits 18715 18734 +19
Misses 787 787
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
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'm not sure we should add multiprocessing logic in the message store / message id store directly ? I don't understand why we do it either, as the content of the message id store should never ever change ?
Regarding the timing for 4.0, we don't have a pylint version compatible with python 3.14 and it's been out for around a week now, I'd like to release today. Maybe this can wait for 4.1.0 (and 4.1.0 can come very fast) ? ("last minute multiprocessing fix" did sound ominous but I was expecting something less complex to be honest)
Technically they should change whenever we fully remove / deregister a checker. That's just nothing we have done so far. The re-register was assumed to be save as it overwrites the entries in the message store with the same contents. Technically it works which is why we could remove the message de-register logic. Will include that in the next commits.
Will move it to |
Why would we want to deregister a checker ? Once the configuration is read all checkers and extensions are "final", right ? I had a plan that I never opened an issue for to have a generated static base for the message id store / message store with all the messages from the known checkers / extensions, then only deal dynamically with external plugin's message (to have a better startup time, obviously). Is there something wrong with this approach ? |
d823189
to
9f7483f
Compare
We do pylint/pylint/lint/parallel.py Lines 55 to 58 in 6ce6032
Not that I can think of. The original code worked because re-registering a message with the same definition is basically a no-op. In contrast to the checker itself which get's added twice. |
This comment has been minimized.
This comment has been minimized.
b92d0d5
to
175f75b
Compare
This comment has been minimized.
This comment has been minimized.
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.
Thanks, I like how you avoided the need to cache the enables and disables and instead just made the re-registration more of a no-op.
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.
Great second draft ! A lot simpler, and not touching the message stores anymore. Maybe we could cover more of the new code with tests ?
This comment has been minimized.
This comment has been minimized.
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 5ec6ad9 |
Description
Fix two multiprocessing issues.
Not possible to enable extension checks with
"default_enabled": False
Whenever
register_checker
is called it overwrites the message filter in case a message is disabled by default. Usually that isn't an issue as the checkers are first registered and the config loaded afterwards.pylint/pylint/lint/pylinter.py
Lines 495 to 504 in 6ce6032
For multiple jobs the dynamic checkers are re-registered though which overwrites the previously loaded config. To resolve that, it's necessary to restore the message state by caching the list of enabled and disabled messages and reapplying it.
pylint/pylint/lint/parallel.py
Lines 55 to 58 in 6ce6032
Closes #10037
Warnings are emitted multiple times
Whenever a checker get's registered, it's just appended to the list of checkers with the corresponding checker name. That's necessary to allow multiple modules to register the same checker name.
pylint/pylint/lint/pylinter.py
Lines 495 to 497 in 6ce6032
When the checker is now re-registered during the worker init, the "old" one is still active. Thus any message is actually printed twice. To resolve it, deregister the "old" dynamic checkers before loading them again.