A local run never closes its LocalCluster, so in-process main() runs leave dask workers alive

Aperta Adatta ai principianti
#1,063 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia in pybnf/cluster.py, in corrispondenza di Cluster.__init__ e Cluster.teardown; segui la creazione dei cluster locali e il percorso di errore durante l’avvio locale. Leggi tests/lwf_harness.run_main e i test che eseguono chiamate a main() nello stesso processo. Il lavoro è terminato quando il teardown rilascia i worker locali nei percorsi normali e in quelli di errore; conferma che le esecuzioni ripetute non lasciano worker attivi e che il comportamento di ssh, srun e scheduler_file rimane invariato.

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

Descrizione

Cluster.__init__ in pybnf/cluster.py builds the local cluster as

lc = LocalCluster(**lc_kwargs)
self.client = Client(lc)

and keeps no reference to lc. Cluster.teardown() only calls self.client.close(). In distributed, Client.close() closes a cluster only when the client created that cluster itself (Client() with no address). A cluster object handed to Client(...) is left running. So the LocalCluster and its worker processes stay alive until the Python process exits.

A command-line run exits right after teardown, so users don't see this. Every in-process pybnf.main() run does see it. That includes tests/lwf_harness.run_main and the tests that use it: each such run leaves its workers alive for the rest of the pytest process. A review of another branch counted 320 live dask worker children in one pytest process, which slows the suite down.

Reproduced on main at 292774b0 with distributed 2026.7.1. Two in-process main() runs with parallel_count = 2 each started a LocalCluster with two spawned workers. After each run returned, its LocalCluster still reported Status.running and both of its workers were still alive. The runs' error path leaks the same way, because main()'s finally tears down only the client.

Fix: keep the LocalCluster on the Cluster and close it in teardown, after the client. Also close it if local bring-up fails after the cluster starts. The ssh, srun and scheduler_file paths are unaffected, because PyBNF does not own a LocalCluster there.

Lingua principale
Python
Stelle
26
Fork
25
Merge medio
4h 9m
PR unite (30g)
11

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 lanl/PyBNF

Tutte le issue di lanl/PyBNF

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.