Skip to content

test: ignore Python 3.15 fork-with-threads DeprecationWarning in test_multiprocessing#221

Open
d-v-b wants to merge 2 commits into
mainfrom
claude/zarr-python-4086-8cc808
Open

test: ignore Python 3.15 fork-with-threads DeprecationWarning in test_multiprocessing#221
d-v-b wants to merge 2 commits into
mainfrom
claude/zarr-python-4086-8cc808

Conversation

@d-v-b

@d-v-b d-v-b commented Jul 13, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Fixes zarr-developers#4086

Problem

Python 3.15 makes os.fork() emit DeprecationWarning: This process is multi-threaded, use of fork() may lead to deadlocks in the child whenever the forking process has more than one thread (python/cpython#84559). By the time test_multiprocessing calls ctx.Pool(), zarr's sync bridge has already started its dedicated zarr_io event-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 with filterwarnings = ["error"], the two fork parametrizations fail on 3.15.

Fix

Add a targeted pytest.mark.filterwarnings ignore to the fork param only, matching the exact 3.15 message. The warning is emitted in the parent during os.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_fork handler in zarr/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):

  • With zarr from this branch, threads at fork time are ['MainThread', 'zarr_io', 'asyncio_0'] — zarr's own threads trigger the deprecation, no xdist involved.
  • Without the filter, the exact DeprecationWarning from the issue is raised under warnings-as-errors.
  • With the filter regex from this PR, the fork Pool roundtrip completes on 3.15 and the child processes return correct data — i.e. zarr's register_at_fork handling still works there.
  • pytest tests/test_array.py::test_multiprocessing passes on macOS (fork params skip; spawn/forkserver pass).

🤖 Generated with Claude Code

…_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
d-v-b force-pushed the claude/zarr-python-4086-8cc808 branch from 97a43e3 to ef7863a Compare July 13, 2026 16:00
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.

test_multiprocessing[fork] fails on Python 3.15

1 participant