Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test_coverage_stop_in_threads fails consistently on python 3.14 #2109

@Aleksanaa

Description

@Aleksanaa

Describe the bug

This test fails consistently in multiple runs with python 3.14

________________________ test_coverage_stop_in_threads _________________________
[gw1] linux -- Python 3.14.2 /nix/store/pmb8clh66mryha2ijzz3dg969drrkgj7-python3-3.14.2/bin/python3.14

    @pytest.mark.skipif(not testenv.SETTRACE_CORE, reason="gettrace is not supported with this core.")
    def test_coverage_stop_in_threads() -> None:
        has_started_coverage = []
        has_stopped_coverage = []

        def run_thread() -> None:  # pragma: nested
            """Check that coverage is stopping properly in threads."""
            deadline = time.time() + 5
            ident = threading.current_thread().ident
            if sys.gettrace() is not None:
                has_started_coverage.append(ident)
            while sys.gettrace() is not None:
                # Wait for coverage to stop
                time.sleep(0.01)
                if time.time() > deadline:
                    return
            has_stopped_coverage.append(ident)

        cov = coverage.Coverage()
        with cov.collect():
            t = threading.Thread(target=run_thread)
            t.start()

            time.sleep(0.1)
        t.join()

>       assert has_started_coverage == [t.ident]
E       assert [] == [140737212749504]
E
E         Right contains one more item: 140737212749504
E
E         Full diff:
E         + []
E         - [
E         -     140737212749504,
E         - ]

tests/test_concurrency.py:670: AssertionError
=========================== short test summary info ============================
FAILED tests/test_concurrency.py::test_coverage_stop_in_threads - assert [] == [140737212749504]

  Right contains one more item: 140737212749504

  Full diff:
  + []
  - [
  -     140737212749504,
  - ]
=================== 1 failed, 215 passed, 1 skipped in 3.98s ===================

To Reproduce

nix build nixpkgs#python314Packages.coverage, or better run tests yourself

Answer the questions below:

  1. What version of Python are you using? 3.14.2
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful. 7.13.0
  3. What versions of what packages do you have installed? The output of pip freeze is helpful.
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
  5. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions