Skip to content

Hang on Windows with newest release 7.13.3 #2128

Description

@uellue

Describe the bug

Pytest hangs when coverage is collected with coverage==7.13.3 on Windows under specific conditions: run with tox and exercising some code that starts a lot of threads, processes, etc in non-trivial Python projects -- not clear what exactly triggers it. The issue is reliably reproduced on my system.

To Reproduce

At https://github.com/uellue/reprocoverage you find a repository that helps reproduce the issue, with instructions in the README.md.

coverage debug sys

(reprotest313) PS C:\Users\weber\Documents\src\reprocoverage> .\.tox\py313\Scripts\coverage.exe debug sys
-- sys -------------------------------------------------------
               coverage_version: 7.13.3
                coverage_module: C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\coverage\__init__.py
                           core: -none-
                        CTracer: available from C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\coverage\tracer.cp313-win_amd64.pyd
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: C:\Users\weber\Documents\src\reprocoverage\.coveragerc
                                 C:\Users\weber\Documents\src\reprocoverage\.coveragerc.toml
                                 C:\Users\weber\Documents\src\reprocoverage\setup.cfg
                   configs_read: C:\Users\weber\Documents\src\reprocoverage\setup.cfg
                    config_file: C:\Users\weber\Documents\src\reprocoverage\setup.cfg
                config_contents: b"[flake8]\r\nmax-line-length = 100\r\nignore = E24,E121,E123,E126,E128,E133,E226,E241,E242,E704,W503\r\nexclude = .git,__pycache__,.tox,build,dist,node_modules,TOXENV\r\n\r\n[coverage:run]\r\nbranch = True\r\ninclude = src/\r\n\r\n[coverage:report]\r\n# Regexes for lines to exclude from consideration\r\nexclude_lines =\r\n    # Have to re-enable the standard pragma\r\n    pragma: no cover\r\n\r\n    # Don't complain about missing debug-only code:\r\n    def __repr__\r\n    if self\\.debug\r\n\r\n    # Don't complain about typing branches:\r\n    if TYPE_CHECKING\r\n    if typing.TYPE_CHECKING\r\n\r\n    # Don't complain if tests don't hit defensive assertion code:\r\n    raise AssertionError\r\n    raise NotImplementedError\r\n\r\n    # Don't complain if non-runnable code isn't run:\r\n    if 0:\r\n    if False:\r\n    if __name__ == .__main__.:\r\n\r\n# note: pytest config moved to pytest.ini beause of https://github.com/pypa/pip/issues/5182 and https://github.com/pytest-dev/pytest/issues/3062\r\n"
                      data_file: -none-
                         python: 3.13.11 | packaged by conda-forge | (main, Jan 26 2026, 23:43:44) [MSC v.1944 64 bit (AMD64)]
                       platform: Windows-2025Server-10.0.26100-SP0
                 implementation: CPython
                          build: ('main', 'Jan 26 2026 23:43:44')
                    gil_enabled: True
                     executable: C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Scripts\python.EXE
                      pth_files: C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\a1_coverage.pth
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 22684
                            cwd: C:\Users\weber\Documents\src\reprocoverage
                           path: C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Scripts\coverage.exe
                                 C:\Users\weber\.conda\envs\reprotest313\python313.zip
                                 C:\Users\weber\.conda\envs\reprotest313\DLLs
                                 C:\Users\weber\.conda\envs\reprotest313\Lib
                                 C:\Users\weber\.conda\envs\reprotest313
                                 C:\Users\weber\Documents\src\reprocoverage\.tox\py313
                                 C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages
                                 C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\win32
                                 C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\win32\lib
                                 C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Lib\site-packages\Pythonwin
                    environment: CONDA_PYTHON_EXE = C:\ProgramData\Miniconda3\python.exe
                                 TEMP = C:\Users\weber\AppData\Local\Temp\3
                                 TMP = C:\Users\weber\AppData\Local\Temp\3
                   command_line: C:\Users\weber\Documents\src\reprocoverage\.tox\py313\Scripts\coverage debug sys
                           time: 2026-02-04 18:01:15

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!

Clone the repo linked above, change into the repo's main folder and follow the instructions in the README.md:

  • On Windows (tested with Windows Server 2025 Standard) create and activate a Python 3.13 environment, e.g.
    • conda create -n reprocoverage313 python=3.13
    • conda activate reprocoverage313
  • Install tox: pip install tox
  • Run tox: tox -e py313

What happens

pytest hangs on the second test.

What should happen

pytest runs through.

How to make it not hang

a) Pin the coverage version in pyproject.toml to coverage<7.13.3

b) Remove the --cov=libertem in tox.ini

CC @sk1p

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions