`multiprocessing.Pool` is incompatible with `concurrent.interpreters`
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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