mirror of
https://github.com/python/cpython.git
synced 2024-11-28 20:33:54 +08:00
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341)
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
This commit is contained in:
parent
a7e251b07a
commit
85b920498b
@ -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
|
||||
|
||||
|
@ -2286,6 +2286,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'
|
||||
|
@ -0,0 +1 @@
|
||||
Pass multiprocessing BaseProxy argument `manager_owned` through AutoProxy
|
@ -0,0 +1,2 @@
|
||||
Add test for nested queues when using ``multiprocessing`` shared objects
|
||||
``AutoProxy[Queue]`` inside ``ListProxy`` and ``DictProxy``
|
Loading…
Reference in New Issue
Block a user