self._manager is None when proxy gets passed between processes and causes AttributeError
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Tái hiện lỗi bằng ví dụ test.py tối thiểu, sau đó kiểm tra Lib/multiprocessing/managers.py xung quanh BaseProxy._callmethod và PR được liên kết gh-99598. Công việc được xem là hoàn tất khi một proxy được truyền sang tiến trình khác có thể gọi make_child mà không gặp AttributeError và hồi quy được bao phủ bằng một bài kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
When a proxy derived from multiprocessing.managers.BaseProxy is passed between processes, the self._manager attribute becomes None. self._manager is however accessed to retrieve its _registry attribute, which contain the method_to_typeid map recorded into the manager viaBaseManager.register(), causing an AttributeError. The solution is to decouple the role of the manager from the role of the registry and propagate the registry separately. I'll submit a pull request to fix this.
Minimal failing example
test.py
from multiprocessing import Process
from multiprocessing.managers import BaseProxy, BaseManager
class Parent(object):
def __init__(self, *args, **kwargs):
pass
def make_child(self):
return Parent()
class MyManager(BaseManager):
pass
def child_generator(parent):
parent.make_child()
if __name__ == "__main__":
MyManager.register('Parent', callable=Parent,
method_to_typeid={'make_child': 'Parent'})
with MyManager() as manager:
parent = manager.Parent()
process = Process(target=child_generator, args=(parent, ))
process.start()
process.join()
Output
❯ python3 test.py
Process Process-2:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "test.py", line 18, in child_generator
parent.make_child()
File "<string>", line 2, in make_child
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/managers.py", line 824, in _callmethod
proxytype = self._manager._registry[token.typeid][-1]
AttributeError: 'NoneType' object has no attribute '_registry'
Environment
- CPython versions tested on: 3.6, 3.7, 3.8, 3.9, 3.10
- Operating system and architecture: macOS Monterey 12.6
Linked PRs
- gh-99598
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
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.
Issue khác của python/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
PolicyEngine/policyengine-us#9559 ·
-
priority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
googleapis/librarian#7636 ·
-
from:qa priority:P2 reliability tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
spec-kitty/spec-kitty#4874 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100