test: ignore Python 3.15 fork-with-threads DeprecationWarning in test_multiprocessing#221
Open
d-v-b wants to merge 2 commits into
Open
test: ignore Python 3.15 fork-with-threads DeprecationWarning in test_multiprocessing#221d-v-b wants to merge 2 commits into
d-v-b wants to merge 2 commits into
Conversation
…_multiprocessing Python 3.15 makes os.fork() emit a DeprecationWarning when the process has multiple threads (python/cpython#84559). zarr's sync event-loop thread is always running by the time test_multiprocessing forks, and the suite runs with filterwarnings = ["error"], so the fork parametrizations fail on 3.15. Fork-safety despite those threads is exactly what this test pins down (zarr registers an os.register_at_fork handler), so keep the coverage and ignore the warning with a targeted per-param filter. Fixes zarr-developers#4086 Assisted-by: ClaudeCode:claude-fable-5
d-v-b
force-pushed
the
claude/zarr-python-4086-8cc808
branch
from
July 13, 2026 16:00
97a43e3 to
ef7863a
Compare
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.
🤖 AI text below 🤖
Fixes zarr-developers#4086
Problem
Python 3.15 makes
os.fork()emitDeprecationWarning: This process is multi-threaded, use of fork() may lead to deadlocks in the childwhenever the forking process has more than one thread (python/cpython#84559). By the timetest_multiprocessingcallsctx.Pool(), zarr's sync bridge has already started its dedicatedzarr_ioevent-loop thread, so the parent is always multi-threaded — even under plain single-process pytest (the issue attributes the threads to pytest-xdist, but xdist is incidental). Because the suite runs withfilterwarnings = ["error"], the twoforkparametrizations fail on 3.15.Fix
Add a targeted
pytest.mark.filterwarningsignore to theforkparam only, matching the exact 3.15 message. The warning is emitted in the parent duringos.fork(), so a per-test marker catches it. Note the message part is a real regex here: pytest's ini/marker filter parser does not escape it (unlike stdlib-W), so the escaped parens/\d+are correct.Skipping fork on 3.15+ was rejected: zarr deliberately supports fork via its
os.register_at_forkhandler inzarr/core/sync.py, and this test is what pins that behavior. The coverage should keep running for as long as CPython supports fork-with-threads.Verification
Reproduced and verified on CPython 3.15.0b3 (uv-installed, numpy/numcodecs built from source):
['MainThread', 'zarr_io', 'asyncio_0']— zarr's own threads trigger the deprecation, no xdist involved.DeprecationWarningfrom the issue is raised under warnings-as-errors.Poolroundtrip completes on 3.15 and the child processes return correct data — i.e. zarr'sregister_at_forkhandling still works there.pytest tests/test_array.py::test_multiprocessingpasses on macOS (fork params skip; spawn/forkserver pass).🤖 Generated with Claude Code