-
-
Notifications
You must be signed in to change notification settings - Fork 674
Fix multiprocessing start method for Python 3.14 compatibility #41023
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
Fix multiprocessing start method for Python 3.14 compatibility #41023
Conversation
Python 3.14 changed the default multiprocessing start method from 'fork' to 'forkserver' on Linux. This caused pickling errors in the doctest framework because DocTestWorker objects contained unpicklable local functions. The fix ensures that the 'fork' start method is always used on all platforms, not just macOS, since Sage's doctesting framework requires the 'fork' method to function correctly. Changes: - src/sage/doctest/forker.py: Remove Darwin-only check, always use fork - src/sage/doctest/external.py: Remove Darwin-only check, always use fork
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.
Pull Request Overview
This PR fixes multiprocessing compatibility issues with Python 3.14 by ensuring Sage's doctest framework always uses the 'fork' start method. Python 3.14 changed the default multiprocessing start method from 'fork' to 'forkserver' on Linux, which causes pickling errors in Sage's doctesting framework since DocTestWorker objects contain unpicklable local functions.
- Removes platform-specific (Darwin-only) checks for setting the multiprocessing start method
- Updates comments to explain the Python 3.14 compatibility requirement
- Ensures 'fork' method is used consistently across all platforms
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/sage/doctest/forker.py | Removes Darwin-only check and always sets 'fork' method with updated comment |
src/sage/doctest/external.py | Removes Darwin-only check and always sets 'fork' method with updated comment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Documentation preview for this PR (built with commit b30e0b0; changes) is ready! 🎉 |
@dimpase I think we should move on this. without this, the doctest goes wrong in python 3.14. |
OK |
this should be conditional on the Python version. What's OK for 3.14 is not good for <3.14 |
But seems all CI pass under python 3.13 and older versions. and before python 3.14, the default start method of On Unix platforms other than macOS, “forkserver” is now the the default start method for ProcessPoolExecutor (replacing “fork”). This change does not affect Windows or macOS, where “spawn” remains the default start method. If the threading incompatible fork method is required, you must explicitly request it by supplying a multiprocessing context mp_context to ProcessPoolExecutor. See forkserver restrictions for information and differences with the fork method and how this change may affect existing code with mutable global shared variables and/or shared objects that can not be automatically pickled. Besides, our |
Right, I misread your patch. apologies. All good. |
sagemathgh-41023: Fix multiprocessing start method for Python 3.14 compatibility Python 3.14 changed the default multiprocessing start method from ``fork`` to ``forkserver`` on Linux. This caused pickling errors in the doctest framework because DocTestWorker objects contained unpicklable local functions. The fix ensures that the ``fork`` start method is always used on all platforms, not just macOS, since Sage's doctesting framework requires the 'fork' method to function correctly. Changes: - src/sage/doctest/forker.py: Remove Darwin-only check, always use fork - src/sage/doctest/external.py: Remove Darwin-only check, always use fork <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#41023 Reported by: Chenxin Zhong Reviewer(s): Copilot, Dima Pasechnik
sagemathgh-41023: Fix multiprocessing start method for Python 3.14 compatibility Python 3.14 changed the default multiprocessing start method from ``fork`` to ``forkserver`` on Linux. This caused pickling errors in the doctest framework because DocTestWorker objects contained unpicklable local functions. The fix ensures that the ``fork`` start method is always used on all platforms, not just macOS, since Sage's doctesting framework requires the 'fork' method to function correctly. Changes: - src/sage/doctest/forker.py: Remove Darwin-only check, always use fork - src/sage/doctest/external.py: Remove Darwin-only check, always use fork <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#41023 Reported by: Chenxin Zhong Reviewer(s): Copilot, Dima Pasechnik
Python 3.14 changed the default multiprocessing start method from
fork
toforkserver
on Linux. This caused pickling errors in the doctest framework because DocTestWorker objects contained unpicklable local functions.The fix ensures that the
fork
start method is always used on all platforms, not just macOS, since Sage's doctesting framework requires the 'fork' method to function correctly.Changes:
📝 Checklist
⌛ Dependencies