zarr-developers/numcodecs

Using multiprocessing.set_start_method() after importing numcodecs results in an exception

Opened this issue · 0 comments

Minimal, reproducible code sample, a copy-pastable example if possible

import multiprocessing as mp
import numcodecs

mp.set_start_method("spawn")

Problem description

Trying to use multiprocessing.set_start_method() results in an exception:

Traceback (most recent call last):
  File "/home/mederic/scratch/start_method/test2.py", line 4, in <module>
    mp.set_start_method("spawn")
  File "/usr/lib/python3.12/multiprocessing/context.py", line 248, in set_start_method
    raise RuntimeError('context has already been set')
RuntimeError: context has already been set

It should be possible to set the start method even after importing the package.

Version and installation information

Please provide the following:

  • Value of numcodecs.__version__: 0.12.1
  • Version of Python interpreter: 3.12.3
  • Operating system (Linux/Windows/Mac): Archlinux
  • How NumCodecs was installed (e.g., "using pip into virtual environment", or "using conda"): system package