Message373427
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.
""") |
|
Date |
User |
Action |
Args |
2020-07-09 20:10:20 | Felipe A. Hernandez | set | recipients:
+ Felipe A. Hernandez, pitrou, giampaolo.rodola, davin |
2020-07-09 20:10:20 | Felipe A. Hernandez | set | messageid: <1594325420.21.0.0134943468042.issue35919@roundup.psfhosted.org> |
2020-07-09 20:10:20 | Felipe A. Hernandez | link | issue35919 messages |
2020-07-09 20:10:20 | Felipe A. Hernandez | create | |
|