`multiprocessing.Pool` is incompatible with `concurrent.interpreters`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện ví dụ trên Python 3.14, sau đó kiểm tra Lib/multiprocessing/pool.py và Lib/multiprocessing/queues.py tại phần mã daemon-thread được tham chiếu. Kiểm tra PR được liên kết gh-140238 và hành vi xung quanh của concurrent.interpreters trước khi quyết định liệu kết quả nên là một thay đổi về khả năng tương thích hay tài liệu; hoàn tất khi tính không tương thích đã được giải quyết hoặc được ghi lại rõ ràng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100