Skip to content

Guard multiprocessing logging by the active start method - #107

Draft
Shubham-Padkonde wants to merge 2 commits into
neuroinformatics-unit:mainfrom
Shubham-Padkonde:fix/multiprocessing-start-method
Draft

Shubham-Padkonde wants to merge 2 commits into
neuroinformatics-unit:mainfrom
Shubham-Padkonde:fix/multiprocessing-start-method

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Fixes #106.

multiprocessing-logging requires the fork start method. The existing Windows-only guard still attempts to install its handler with macOS's default spawn, or explicitly selected spawn/forkserver on 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; fork remains 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 actual spawn context before the fix.

Validation on Linux / Python 3.13.14 with the git and multiprocessing extras:

  • 24 functional tests passed (pytest -q -k 'not benchmark').
  • Separate actual spawn, forkserver, and fork processes wrote a log, produced the expected warning behavior, and retained their selected start method.
  • Full pre-commit run --all-files passed, including Ruff, mypy, check-manifest and codespell.
  • The full suite has one existing timing-benchmark failure here. Its 0.13-second threshold is exceeded on both base and changed code, including a native Linux filesystem copy (base: 0.140s; changed: 0.148s). The benchmark and threshold are unchanged.

Native macOS/Windows tests were not run. Submitting as a draft for discussion in line with the NIU contribution guide. Prepared with Codex assistance.

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.35%. Comparing base (95ed0e9) to head (5128d7b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiprocessing logging fails on macOS python 3.13

1 participant