`multiprocessing.Pool` is incompatible with `concurrent.interpreters`
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Trying to create a mutliprocessing.Pool in a sub-interpreter fails due to the use of daemon threads.
How I ran into it: as an experiment, I was trying to run pytest in a sub-interpreter (on its own test suite). One of the tests is using multiprocessing.Pool and fails. (There are other failures, particularly faulthandler and readline incompatibilities, but those are unrelated to this issue).
If mutliprocessing.Pool and concurrent.interpreters are fundamentally incompatible for some reason, perhaps it can be documented.
from concurrent import interpreters
interp = interpreters.create()
interp.exec("""
import multiprocessing
pool = multiprocessing.Pool()
""")
Traceback:
Traceback (most recent call last):
File "x.py", line 5, in <module>
interp.exec("""
~~~~~~~~~~~^^^^
import multiprocessing
^^^^^^^^^^^^^^^^^^^^^^
pool = multiprocessing.Pool()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
""")
^^^^
File "/home/ran/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/concurrent/interpreters/__init__.py", line 212, in exec
raise ExecutionFailed(excinfo)
concurrent.interpreters.ExecutionFailed: RuntimeError: daemon threads are disabled in this interpreter
Uncaught in the interpreter:
Traceback (most recent call last):
File "<script>", line 3, in <module>
File "/home/ran/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/multiprocessing/context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
context=self.get_context())
File "/home/ran/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/multiprocessing/pool.py", line 233, in __init__
self._worker_handler.daemon = True
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ran/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/threading.py", line 1207, in daemon
raise RuntimeError('daemon threads are disabled in this interpreter')
RuntimeError: daemon threads are disabled in this interpreter
Link to relevant code:
I'd also note that multiprocessing.Queue uses daemon thread:
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-140238
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 Python 3.14 上复现该示例,然后检查所引用的 daemon-thread 代码中的 Lib/multiprocessing/pool.py 和 Lib/multiprocessing/queues.py。在决定结果应当是兼容性更改还是文档之前,检查链接的 PR gh-140238 以及 concurrent.interpreters 周边的行为;当不兼容问题得到解决或得到明确记录时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100