Skip to content

Test suite uses unsafe multiprocessing start method fork on Linux #1274

@jakob-keller

Description

@jakob-keller

Describe the bug
Our test suite uses a combination of multiprocessing and multithreading. This can be dangerous when the multiprocessing start method fork is used. Start method spawn would be the safe choice in this context.

By default, current Python releases default to spawn on Windows and macOS, but use fork on Linux, which is what we use in CI/CD. Since Python 3.12, this triggers DeprecationWarnings, such as here:

tests/test_stubber.py::test_add_client_error
/usr/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=2749) is multi-threaded, use of fork() may lead to deadlocks in the child.
self.pid = os.fork()

We should ensure that multiprocessing always uses spawn in the context of our test suite. I will propose a fix.

This could actually also explain the flakiness experienced in #1266. Fingers crossed...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions