diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 77dd1129..89815baa 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -44,6 +44,9 @@ jobs: include: - os: windows-latest python_version: 'msys2' + env: + # Enable tracemalloc to debug gc errors with popen objects (especially on Windows) + PYTHONTRACEMALLOC: "1" name: ${{ matrix.os }} - Python ${{ matrix.python_version }} steps: diff --git a/pyproject.toml b/pyproject.toml index 80cb6443..a8345310 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -164,7 +164,7 @@ filterwarnings = [ log_level = "debug" log_cli_level = "info" # disable unraisable until investigated -addopts = ["-ra", "--strict-config", "--strict-markers", "-p", "no:unraisableexception"] +addopts = ["-ra", "--strict-config", "--strict-markers"] markers = [ "issue(id): reference to github issue", "skip_commit: allows to skip committing in the helpers", diff --git a/src/setuptools_scm/_file_finders/git.py b/src/setuptools_scm/_file_finders/git.py index 0eb23ced..fe6dfb05 100644 --- a/src/setuptools_scm/_file_finders/git.py +++ b/src/setuptools_scm/_file_finders/git.py @@ -84,8 +84,16 @@ def _git_ls_files_and_dirs(toplevel: str) -> tuple[set[str], set[str]]: # ensure we avoid resource warnings by cleaning up the process proc.stdout.close() proc.terminate() + # Wait for process to actually terminate and be reaped + try: + proc.wait(timeout=5) # Add timeout to avoid hanging + except subprocess.TimeoutExpired: + log.warning("git archive process did not terminate gracefully, killing") + proc.kill() + proc.wait() except Exception: - if proc.wait() != 0: + # proc.wait() already called in finally block, check if it failed + if proc.returncode != 0: log.error("listing git files failed - pretending there aren't any") return set(), set()