Skip to content

DeprecationWarning on Python 3.12 from os.fork() #105

Closed

Description

@andersle

I get a DeprecationWarning on Python 3.12 when running the tests, looks like it is related to this https://docs.python.org/3/whatsnew/3.12.html:

On POSIX platforms, os.fork() can now raise a DeprecationWarning when it can detect being called from a multithreaded process. There has always been a fundamental incompatibility with the POSIX platform when doing so. Even if such code appeared to work. We added the warning to raise awareness as issues encountered by code doing this are becoming more frequent. See the os.fork() documentation for more details along with this discussion on fork being incompatible with threads for why we’re now surfacing this longstanding platform compatibility problem to developers.

When this warning appears due to usage of multiprocessing or concurrent.futures the fix is to use a different multiprocessing start method such as "spawn" or "forkserver". ```

Output from the tests:

=============================== warnings summary ===============================
test/runner/test_aiorunner.py::test_runner_check_return_success
test/runner/test_aiorunner.py::test_runner_infretis_mode
test/runner/test_aiorunner.py::test_runner_infretis_mode
test/runner/test_aiorunner.py::test_runner_task_error
  /opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=1876) is multi-threaded, use of fork() may lead to deadlocks in the child.
    self.pid = os.fork()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================= 52 passed, 6 deselected, 4 warnings in 4.48s =================

See also: python/cpython#100229

Activity

  1. dz24 commented on Sep 6, 2024

    @dz24
    Contributor
  2. dz24 commented on Nov 18, 2025

    @dz24
    Contributor

    Should be solved in PR #190.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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