-
-
Notifications
You must be signed in to change notification settings - Fork 32k
GH-113421: Fix multiprocessing logger #113423
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
GH-113421: Fix multiprocessing logger #113423
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
The fix looks reasonable to me. You should probably add a regression test and a news entry to it. |
59d7229
to
772a742
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Test case and news entry have been added to this pull request. |
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 test does not fail with unmodified code. But it produces superfluous output and warnings (because it modifies the global handlers list).
Please make a test that doues not produce unneeded output and warnings, fails when the bug is not fixed, and success if it is fixed.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@serhiy-storchaka |
You test still does NOT fail. A regression test should:
In practice, the following should happen: WITHOUT your source code changes (but with the regression test you added), WITH your source code changes and the regression test you added, |
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 think you are doing a great job. That's what we meant for a regression test. I do have some suggestions to you, but that's basically what I got for now. I'll leave the final approval for @serhiy-storchaka .
Lib/test/_test_multiprocessing.py
Outdated
|
||
def test_filename(self): | ||
logger = multiprocessing.get_logger() | ||
default_level = logger.level |
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 think original_level
might be a more proper name for this. It does not have to be the default level.
Lib/test/_test_multiprocessing.py
Outdated
util.info('2') | ||
logger.debug('3') | ||
filename = os.path.basename(__file__) | ||
self.assert_log_lines([ |
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 think having a utility function might be a bit of an overkill here. Your check is very thorough but it might be too strict. I think something like
output = stream.getvalue()
self.assertIn(f'[INFO] [{filename}] 1', output)
...
should be good enough here. It's clear enough for people about what it's doing, and it's testing against the core issue this PR solves. Making sure the output matches exactly what's expected is not necessarily the best way to do it (especially if it makes the code harder to understand).
Thanks for your instruction. I have made the requested changes. |
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.
LGTM.
Thanks @xu-song for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
…nGH-113423) (cherry picked from commit ce77ee5) Co-authored-by: Xu Song <xusong.vip@gmail.com>
GH-113450 is a backport of this pull request to the 3.12 branch. |
GH-113451 is a backport of this pull request to the 3.11 branch. |
…nGH-113423) (cherry picked from commit ce77ee5) Co-authored-by: Xu Song <xusong.vip@gmail.com>
Thank you @xu-song for your contribution and @gaogaotiantian for guiding it. |
Uh oh!
There was an error while loading. Please reload this page.