]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341) (GH-26989)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 2 Jul 2021 04:35:31 +0000 (21:35 -0700)
committerGitHub <noreply@github.com>
Fri, 2 Jul 2021 04:35:31 +0000 (21:35 -0700)
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
(cherry picked from commit 85b920498b42c69185540ecc2f5c4907fd38d877)

Co-authored-by: finefoot <33361833+finefoot@users.noreply.github.com>
Lib/multiprocessing/managers.py
Lib/test/_test_multiprocessing.py
Misc/NEWS.d/next/Library/2019-09-25-13-54-41.bpo-30256.wBkzox.rst [new file with mode: 0644]
Misc/NEWS.d/next/Tests/2019-09-25-18-10-10.bpo-30256.A5i76Q.rst [new file with mode: 0644]

index 0eb16c664cfab3608f13ac372be2a31491db452d..f8d3cef110fa58d51688a3521cab642d17012fd1 100644 (file)
@@ -959,7 +959,7 @@ def MakeProxyType(name, exposed, _cache={}):
 
 
 def AutoProxy(token, serializer, manager=None, authkey=None,
-              exposed=None, incref=True):
+              exposed=None, incref=True, manager_owned=False):
     '''
     Return an auto-proxy for `token`
     '''
@@ -979,7 +979,7 @@ def AutoProxy(token, serializer, manager=None, authkey=None,
 
     ProxyType = MakeProxyType('AutoProxy[%s]' % token.typeid, exposed)
     proxy = ProxyType(token, serializer, manager=manager, authkey=authkey,
-                      incref=incref)
+                      incref=incref, manager_owned=manager_owned)
     proxy._isauto = True
     return proxy
 
index e47905c863bafa68e06d5d02dddad8da2df8a3f0..ebd44f97003635bb923e24a28322fa32d1beabbd 100644 (file)
@@ -2282,6 +2282,16 @@ class _TestContainers(BaseTestCase):
         self.assertIsInstance(outer[0], list)  # Not a ListProxy
         self.assertEqual(outer[-1][-1]['feed'], 3)
 
+    def test_nested_queue(self):
+        a = self.list() # Test queue inside list
+        a.append(self.Queue())
+        a[0].put(123)
+        self.assertEqual(a[0].get(), 123)
+        b = self.dict() # Test queue inside dict
+        b[0] = self.Queue()
+        b[0].put(456)
+        self.assertEqual(b[0].get(), 456)
+
     def test_namespace(self):
         n = self.Namespace()
         n.name = 'Bob'
diff --git a/Misc/NEWS.d/next/Library/2019-09-25-13-54-41.bpo-30256.wBkzox.rst b/Misc/NEWS.d/next/Library/2019-09-25-13-54-41.bpo-30256.wBkzox.rst
new file mode 100644 (file)
index 0000000..4490803
--- /dev/null
@@ -0,0 +1 @@
+Pass multiprocessing BaseProxy argument `manager_owned` through AutoProxy
diff --git a/Misc/NEWS.d/next/Tests/2019-09-25-18-10-10.bpo-30256.A5i76Q.rst b/Misc/NEWS.d/next/Tests/2019-09-25-18-10-10.bpo-30256.A5i76Q.rst
new file mode 100644 (file)
index 0000000..4a7cfd5
--- /dev/null
@@ -0,0 +1,2 @@
+Add test for nested queues when using ``multiprocessing`` shared objects
+``AutoProxy[Queue]`` inside ``ListProxy`` and ``DictProxy``