Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

https://docs.python.org/3/library/multiprocessing.html#proxy-objects

> If standard (non-proxy) list or dict objects are contained in a referent, 
> modifications to those mutable values will not be propagated through the 
> manager because the proxy has no way of knowing when the values contained 
> within are modified. However, storing a value in a container proxy (which 
> triggers a __setitem__ on the proxy object) does propagate through the 
> manager and so to effectively modify such an item, one could re-assign the 
> modified value to the container proxy

$ ./python.exe
Python 3.8.0a2+ (heads/master:d5a551c269, Feb 26 2019, 15:49:14)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from multiprocessing import Manager
>>> man = Manager()
>>> shared_list = man.dict()
>>> shared_list['a'] = list()
>>> shared_list['a'].append(100)
>>> shared_list
<DictProxy object, typeid 'dict' at 0x1096adc50>
>>> dict(shared_list)
{'a': []}
>>> shared_list['a'] += [1000] # Update and assign
>>> dict(shared_list)
{'a': [1000]}
>>> shared_list['a'] += [1000] # Update and assign
>>> dict(shared_list)
{'a': [1000, 1000]}

----------
nosy: +pitrou, xtreak

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36119>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to