]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#9801: document how list and dict proxies created by Managers behave w.r.t. mutable...
authorGeorg Brandl <georg@python.org>
Fri, 15 Oct 2010 16:19:43 +0000 (16:19 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 15 Oct 2010 16:19:43 +0000 (16:19 +0000)
Doc/library/multiprocessing.rst

index f8327ec2d237828fc510a687578172b8219f32d1..09d6de99769ddc1caf0fc99286bbc484d627a357 100644 (file)
@@ -1284,6 +1284,24 @@ their parent process exits.  The manager classes are defined in the
 
       Create a shared ``list`` object and return a proxy for it.
 
+   .. note::
+
+      Modifications to mutable values or items in dict and list proxies will not
+      be propagated through the manager, because the proxy has no way of knowing
+      when its values or items are modified.  To modify such an item, you can
+      re-assign the modified object to the container proxy::
+
+         # create a list proxy and append a mutable object (a dictionary)
+         lproxy = manager.list()
+         lproxy.append({})
+         # now mutate the dictionary
+         d = lproxy[0]
+         d['a'] = 1
+         d['b'] = 2
+         # at this point, the changes to d are not yet synced, but by
+         # reassigning the dictionary, the proxy is notified of the change
+         lproxy[0] = d
+
 
 Namespace objects
 >>>>>>>>>>>>>>>>>