[issue6766] Cannot modify dictionaries inside dictionaries using Managers from multiprocessing
Terrence Cole
report at bugs.python.org
Sat Jan 30 05:06:22 CET 2010
Terrence Cole <terrence at zettabytestorage.com> added the comment:
Kaushik, in your example, d is a dict proxy, so assignment to d['f'] correctly ferries the assignment (a new normal dict) to the d['f'] in the original process. The new dict, however, is not a dict proxy, it's just a dict, so assignment of d['f']['msg'] goes nowhere. All hope is not lost, however, because the Manager can be forked to new processes. The slightly modified example below shows how this works:
from multiprocessing import Process, Manager
def f(m, d):
d['f'] = m.dict()
d['f']['msg'] = 'I am here'
m = Manager()
d = m.dict()
p = Process(target=f, args=(m,d))
p.start()
p.join()
print d
{'f': <DictProxy object, typeid 'dict' at 0x7f1517902810>}
print d['f']
{'msg': 'I am here'}
With the attached patch, the above works as shown, without, it gives the same output as your original example.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6766>
_______________________________________
More information about the Python-bugs-list
mailing list