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

未关闭 适合新手
#1,063 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

从 pybnf/cluster.py 中的 Cluster.__init__ 和 Cluster.teardown 开始,跟踪本地集群的创建过程和本地启动失败路径。阅读 tests/lwf_harness.run_main 以及在同一进程中运行 main() 的测试。完成标准是 teardown 在正常和错误路径下都释放本地 worker;确认重复运行后没有 worker 仍在运行,同时 ssh、srun 和 scheduler_file 的行为不受影响。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
26
派生
25
平均合并
4 小时 9 分钟
30 天内合并 PR
11

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lanl/PyBNF 的其他 Issue

查看 lanl/PyBNF 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。