[Bug] Unclosed files, pipes and SQLite connections reported by Python dev mode

Aperta
#8,121 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, sqlite
Ambito
backend, testing

Direzione di ricerca

This is a tracking issue; start with sub-issues #8122 and #8123, which contain the reproducers and specific leak findings. Set PYTHONDEVMODE=1 and run the relevant Python tests or gunittest suite to reproduce warnings. Done means both sub-issues are fixed and GRASS code produces no ResourceWarning.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Python tests

Describe the bug

I made an agent (Claude Code) and asked it to find the places where we open a file or a socket and never close it. It built GRASS, then ran the pytest tests and the full gunittest testsuite (with the NC sample dataset, as in the Ubuntu CI job) with Python's development mode (python -X dev, or PYTHONDEVMODE=1 so that tool scripts started as subprocesses are covered too). Dev mode enables ResourceWarning, which reports files, pipes and database connections that are never closed. The agent then traced each warning back to the code, did a static pass over the rest of the code, and wrote reproducers, which it ran on main at commit 79cd2b35f714274b60df4ef91e2f385c8e3d1197.

This is a tracking issue. The findings are split into two sub-issues, each with its own reproducers:

  • #8122: unclosed files and pipes in tool scripts and Python modules. Small, independent leaks that should be easy to fix, in small PRs grouped by tool.
  • #8123: grass.temporal never closes its SQLite connections. This is the largest source of warnings (over 3,000 in a full gunittest run), but it is not a one-line fix and needs a full temporal test run.

To reproduce

See the sub-issues. In general, set PYTHONDEVMODE=1 (and optionally PYTHONTRACEMALLOC=20 for the place where the object was opened) and run the Python tests or the gunittest testsuite.

Expected behavior

A run with PYTHONDEVMODE=1 prints no ResourceWarning from GRASS code.

Additional context

Once both sub-issues are fixed, the Python tests could run in CI with -X dev -W error::ResourceWarning, or at least report ResourceWarning, so new leaks are caught. Doing it before the grass.temporal issue is fixed would fail everywhere.

Lingua principale
C
Stelle
1.2k
Fork
447
Merge medio
2g 10h
PR unite (30g)
86

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OSGeo/grass

Tutte le issue di OSGeo/grass

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.