silx-kit / silx

silx toolkit
http://www.silx.org/doc/silx/latest/
MIT License
119 stars 70 forks source link

h5py_utils fork deprecation warning #4101

Open t20100 opened 3 months ago

t20100 commented 3 months ago

With Python3.12, this deprecation warning is raised during the tests:

io/test/test_h5py_utils.py: 10 warnings
  multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=770) is multi-threaded, use of fork() may lead to deadlocks in the child.
    self.pid = os.fork()

From os.fork documentation:

Changed in version 3.12: If Python is able to detect that your process has multiple threads, os.fork() now raises a DeprecationWarning.

We chose to surface this as a warning, when detectable, to better inform developers of a design problem that the POSIX platform specifically notes as not supported. Even in code that appears to work, it has never been safe to mix threading with os.fork() on POSIX platforms. The CPython runtime itself has always made API calls that are not safe for use in the child process when threads existed in the parent (such as malloc and free).

Users of macOS or users of libc or malloc implementations other than those typically found in glibc to date are among those already more likely to experience deadlocks running such code.

See this discussion on fork being incompatible with threads for technical details of why we’re surfacing this longstanding platform compatibility problem to developers.

attn @woutdenolf