Message336644
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]} |
|
Date |
User |
Action |
Args |
2019-02-26 11:01:29 | xtreak | set | recipients:
+ xtreak, pitrou, andrei2peu |
2019-02-26 11:01:29 | xtreak | set | messageid: <1551178889.11.0.0755203353472.issue36119@roundup.psfhosted.org> |
2019-02-26 11:01:29 | xtreak | link | issue36119 messages |
2019-02-26 11:01:28 | xtreak | create | |
|