Repository navigation
Guard multiprocessing logging by the active start method - #107
Draft
Shubham-Padkonde wants to merge 2 commits into
Draft
Shubham-Padkonde wants to merge 2 commits into
Shubham-Padkonde wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #107 +/- ##
==========================================
+ Coverage 78.12% 80.35% +2.23%
==========================================
Files 3 3
Lines 224 224
==========================================
+ Hits 175 180 +5
+ Misses 49 44 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
multiprocessing.get_start_method() without allow_none sets the default context as a side effect, so a later set_start_method() call made by the user after start_logging() would raise RuntimeError. Read it with allow_none=True and fall back to the platform default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
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.
Fixes #106.
multiprocessing-loggingrequires theforkstart method. The existing Windows-only guard still attempts to install its handler with macOS's defaultspawn, or explicitly selectedspawn/forkserveron Linux, causing an assertion instead of starting logging.Check the active start method before installing the handler. Unsupported methods emit a warning and retain ordinary logging;
forkremains supported. The check does not run when multiprocessing logging is disabled, and does not change the application's start method. Both public logging docstrings describe the fallback.Tests cover both unsupported methods, successful handler installation with
fork, and the opt-out path. The two unsupported-method regressions fail before the fix and pass afterward. I also reproduced the dependency assertion with an actualspawncontext before the fix.Validation on Linux / Python 3.13.14 with the git and multiprocessing extras:
pytest -q -k 'not benchmark').spawn,forkserver, andforkprocesses wrote a log, produced the expected warning behavior, and retained their selected start method.pre-commit run --all-filespassed, including Ruff, mypy, check-manifest and codespell.Native macOS/Windows tests were not run. Submitting as a draft for discussion in line with the NIU contribution guide. Prepared with Codex assistance.