[Python-checkins] bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341)
gvanrossum
webhook-mailer at python.org
Thu Jul 1 23:45:33 EDT 2021
https://github.com/python/cpython/commit/85b920498b42c69185540ecc2f5c4907fd38d877
commit: 85b920498b42c69185540ecc2f5c4907fd38d877
branch: main
author: finefoot <33361833+finefoot at users.noreply.github.com>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2021-07-01T20:45:02-07:00
summary:
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341)
Co-authored-by: Jordan Speicher <jordan at jspeicher.com>
files:
A Misc/NEWS.d/next/Library/2019-09-25-13-54-41.bpo-30256.wBkzox.rst
A Misc/NEWS.d/next/Tests/2019-09-25-18-10-10.bpo-30256.A5i76Q.rst
M Lib/multiprocessing/managers.py
M Lib/test/_test_multiprocessing.py
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 6ee9521c76b48f..b981b0e1cb8ed8 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -967,7 +967,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`
'''
@@ -987,7 +987,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
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index ead92cfa2abfea..4c4da24a30c371 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2286,6 +2286,16 @@ def test_dict_proxy_nested(self):
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
index 00000000000000..4490803f32642e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-09-25-13-54-41.bpo-30256.wBkzox.rst
@@ -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
index 00000000000000..4a7cfd52fcea22
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-09-25-18-10-10.bpo-30256.A5i76Q.rst
@@ -0,0 +1,2 @@
+Add test for nested queues when using ``multiprocessing`` shared objects
+``AutoProxy[Queue]`` inside ``ListProxy`` and ``DictProxy``
More information about the Python-checkins
mailing list