[issue35919] multiprocessing: shared manager Pool fails with AttributeError
Felipe A. Hernandez
report at bugs.python.org
Thu Jul 9 16:10:20 EDT 2020
Felipe A. Hernandez <ergoithz at gmail.com> added the comment:
import traceback
import multiprocessing.managers
class MyManager(multiprocessing.managers.SyncManager):
pass
class DictList(multiprocessing.managers.BaseProxy):
_method_to_typeid_ = {'__getitem__': 'dict'}
def __getitem__(self, key):
return self._callmethod('__getitem__', (key,))
MyManager.register('DictList', None, DictList)
with MyManager() as manager:
nested = manager.DictList([{'hello': 'world'}])
print(nested[0]['hello']) # world
proxy = manager.list([nested])
try:
print(proxy[0][0]['hello'])
except AttributeError:
traceback.print_exc()
print("""
Bug: AttributeError: ProxyBase._callmethod is None
--------------------------------------------------
This error is raised because proxies returned as #RETURN messages
have no manager reference, which is required to resolve typeids
(using BaseManager._registry).
Only proxies returned as #PROXY messages will be fully functional.
This is an undocumented current implementation limitation.
Fix (proposal)
--------------
Include the manager class (not the instance) as part of the proxy
serialization in BaseProxy.__reduce__, as BaseManager._registry is
a class variable.
Note: #PROXY message protocol can be also replaced by regular proxy
serialization after this fix, resulting on simpler codebase.
""")
----------
nosy: +Felipe A. Hernandez
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35919>
_______________________________________
More information about the Python-bugs-list
mailing list