Skip to content

Commit 8aa45de

Browse files
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341) (GH-26989)
Co-authored-by: Jordan Speicher <[email protected]> (cherry picked from commit 85b9204) Co-authored-by: finefoot <[email protected]>
1 parent 67e3945 commit 8aa45de

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

Lib/multiprocessing/managers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ def MakeProxyType(name, exposed, _cache={}):
959959

960960

961961
def AutoProxy(token, serializer, manager=None, authkey=None,
962-
exposed=None, incref=True):
962+
exposed=None, incref=True, manager_owned=False):
963963
'''
964964
Return an auto-proxy for `token`
965965
'''
@@ -979,7 +979,7 @@ def AutoProxy(token, serializer, manager=None, authkey=None,
979979

980980
ProxyType = MakeProxyType('AutoProxy[%s]' % token.typeid, exposed)
981981
proxy = ProxyType(token, serializer, manager=manager, authkey=authkey,
982-
incref=incref)
982+
incref=incref, manager_owned=manager_owned)
983983
proxy._isauto = True
984984
return proxy
985985

Lib/test/_test_multiprocessing.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,6 +2282,16 @@ def test_dict_proxy_nested(self):
22822282
self.assertIsInstance(outer[0], list) # Not a ListProxy
22832283
self.assertEqual(outer[-1][-1]['feed'], 3)
22842284

2285+
def test_nested_queue(self):
2286+
a = self.list() # Test queue inside list
2287+
a.append(self.Queue())
2288+
a[0].put(123)
2289+
self.assertEqual(a[0].get(), 123)
2290+
b = self.dict() # Test queue inside dict
2291+
b[0] = self.Queue()
2292+
b[0].put(456)
2293+
self.assertEqual(b[0].get(), 456)
2294+
22852295
def test_namespace(self):
22862296
n = self.Namespace()
22872297
n.name = 'Bob'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pass multiprocessing BaseProxy argument `manager_owned` through AutoProxy
Lines changed: 2 additions & 0 deletions
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)