Skip to content

Python 3.15: DeprecationWarning about fork+threads in test_clear_thread_cache_after_fork #3355

@musicinmybrain

Description

@musicinmybrain

In early Fedora integration work with development versions of Python 3.15, we found that test_clear_thread_cache_after_fork fails with the following DeprecationWarning:

=================================== FAILURES ===================================
______________________ test_clear_thread_cache_after_fork ______________________

    @pytest.mark.skipif(not hasattr(os, "fork"), reason="os.fork isn't supported")
    def test_clear_thread_cache_after_fork() -> None:
        assert hasattr(os, "fork")
    
        def foo() -> None:
            pass
    
        # ensure the thread cache exists
        done = threading.Event()
        start_thread_soon(foo, lambda _: done.set())
        done.wait()
    
>       child_pid = os.fork()
E       DeprecationWarning: This process (pid=1741) is multi-threaded, use of fork() may lead to deadlocks in the child.

../BUILDROOT/usr/lib/python3.15/site-packages/trio/_core/_tests/test_thread_cache.py:213: DeprecationWarning
=========================== short test summary info ============================
FAILED _core/_tests/test_thread_cache.py::test_clear_thread_cache_after_fork
====== 1 failed, 695 passed, 85 skipped, 8 deselected, 3 xfailed in 6.34s ======

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