PyAutoFit: importing autofit fixes the multiprocessing start method, so set_start_method() raises on macOS (test suite cannot load conftest) #27
Unanswered
samlange04
asked this question in
Bugs & Errors
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Package: PyAutoFit (
autofit), currentmain(891fe64b9). Platform: macOS, Python 3.13.7.What happens
Importing
autofitand then choosing a multiprocessing start method fails:The autofit test suite does exactly this on macOS in
test_autofit/conftest.py(line 18,multiprocessing.set_start_method("fork")), so on a Mac plainpython -m pytest test_autofithas failed to load the conftest at all since 2026-07-31:Any user script that imports autofit before calling
set_start_methodhits the same error.Cause
Commit e6279c53f ("fix: pin multiprocessing pools to the fork start method") added
autofit/non_linear/parallel/context.py::fork_context(). On Linux it returnsmultiprocessing.get_context("fork"), which is fine: passing a method name does not touch the interpreter default. On macOS and Windows it falls through tomultiprocessing.get_context()with no argument. That call permanently fixes_default_context._actual_context, andfork_context()runs at import time becauseautofit/non_linear/parallel/process.pydoesclass Process(fork_context().Process). Anything that later callsset_start_methodwithoutforce=Trueraises.Traced by patching
multiprocessing.context._default_context.get_contextand printing the stack on the first call while the context was still unset: it fires fromprocess.py:47 -> context.py:33.Proposed fix
On macOS/Windows return the
multiprocessingmodule itself instead ofget_context(). It exposes the sameProcess/Queue/PoolAPI, but resolves the start method when a process is created, which is the pre-3.14 behaviourfork_context()exists to preserve. Linux behaviour (pinned"fork") is unchanged.Branch: https://github.com/samlange04/PyAutoFit/tree/fix/multiprocessing-context-import-time. With it applied, plain
python -m pytest test_autofiton macOS loads the conftest and gives 2924 passed, 39 skipped, 1 failed, and the one failure (test_pdf.py::test_save_covariance_matrix, a last-digit float text comparison) fails identically on unmodifiedmain.PR: PyAutoLabs/PyAutoFit#1657
All reactions