zarr-developers / numcodecs

A Python package providing buffer compression and transformation codecs for use in data storage and communication applications.
http://numcodecs.readthedocs.io
MIT License
125 stars 87 forks source link

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

Open mboquien opened 5 months ago

mboquien commented 5 months ago

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: