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

Abierto Apto para principiantes
#1,063 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Empieza en pybnf/cluster.py, en Cluster.__init__ y Cluster.teardown; sigue la creación de clústeres locales y la ruta de fallo al iniciar el clúster local. Lee tests/lwf_harness.run_main y las pruebas que ejecutan llamadas a main() en el mismo proceso. El trabajo estará terminado cuando el teardown libere los workers locales tanto en las rutas normales como en las de error; confirma que las ejecuciones repetidas no dejan ningún worker activo y que el comportamiento de ssh, srun y scheduler_file no se ve afectado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
26
Forks
25
Merge medio
4 h 9 min
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lanl/PyBNF

Todos los issues de lanl/PyBNF

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.