Skip to content

Commit 85b9204

Browse files
finefootuSpike
andauthored
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341)
Co-authored-by: Jordan Speicher <[email protected]>
1 parent a7e251b commit 85b9204

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

Lib/multiprocessing/managers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ def MakeProxyType(name, exposed, _cache={}):
967967

968968

969969
def AutoProxy(token, serializer, manager=None, authkey=None,
970-
exposed=None, incref=True):
970+
exposed=None, incref=True, manager_owned=False):
971971
'''
972972
Return an auto-proxy for `token`
973973
'''
@@ -987,7 +987,7 @@ def AutoProxy(token, serializer, manager=None, authkey=None,
987987

988988
ProxyType = MakeProxyType('AutoProxy[%s]' % token.typeid, exposed)
989989
proxy = ProxyType(token, serializer, manager=manager, authkey=authkey,
990-
incref=incref)
990+
incref=incref, manager_owned=manager_owned)
991991
proxy._isauto = True
992992
return proxy
993993

Lib/test/_test_multiprocessing.py

+10
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,16 @@ def test_dict_proxy_nested(self):
22862286
self.assertIsInstance(outer[0], list) # Not a ListProxy
22872287
self.assertEqual(outer[-1][-1]['feed'], 3)
22882288

2289+
def test_nested_queue(self):
2290+
a = self.list() # Test queue inside list
2291+
a.append(self.Queue())
2292+
a[0].put(123)
2293+
self.assertEqual(a[0].get(), 123)
2294+
b = self.dict() # Test queue inside dict
2295+
b[0] = self.Queue()
2296+
b[0].put(456)
2297+
self.assertEqual(b[0].get(), 456)
2298+
22892299
def test_namespace(self):
22902300
n = self.Namespace()
22912301
n.name = 'Bob'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pass multiprocessing BaseProxy argument `manager_owned` through AutoProxy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add test for nested queues when using ``multiprocessing`` shared objects
2+
``AutoProxy[Queue]`` inside ``ListProxy`` and ``DictProxy``

0 commit comments

Comments
 (0)