Skip to content

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

@mboquien

Description

@mboquien

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions