Skip to content

Commit 8d946da

Browse files
committed
Addressed code review comments
1 parent a259b39 commit 8d946da

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

Doc/library/multiprocessing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,9 +1952,9 @@ their parent process exits. The manager classes are defined in the
19521952
container object such as a shared list can contain other shared objects
19531953
which will all be managed and synchronized by the :class:`SyncManager`.
19541954

1955-
.. versionchanged:: next
1956-
Add support for shared :class:`set`\s to :class:`multiprocessing.managers.SyncManager`
1957-
via :meth:`SyncManager.set() <multiprocessing.managers.SyncManager.set>`.
1955+
.. method:: set()
1956+
1957+
.. versionadded:: next
19581958

19591959
.. class:: Namespace
19601960

Lib/multiprocessing/managers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,7 @@ class SyncManager(BaseManager):
12821282
SyncManager.register('Value', Value, ValueProxy)
12831283
SyncManager.register('Array', Array, ArrayProxy)
12841284
SyncManager.register('Namespace', Namespace, NamespaceProxy)
1285+
12851286
# types returned by methods of PoolProxy
12861287
SyncManager.register('Iterator', proxytype=IteratorProxy, create_method=False)
12871288
SyncManager.register('AsyncResult', create_method=False)

Lib/test/_test_multiprocessing.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6455,6 +6455,7 @@ def _test_set_operator_symbols(cls, obj):
64556455
obj |= {'d', 'e'}
64566456
case.assertSetEqual(obj, {'a', 'b', 'c', 'd', 'e'})
64576457
case.assertIsInstance(obj, multiprocessing.managers.SetProxy)
6458+
64586459
obj.clear()
64596460
obj.update(['a', 'b', 'c'])
64606461
result = {'a', 'b', 'd'} - obj
@@ -6464,6 +6465,7 @@ def _test_set_operator_symbols(cls, obj):
64646465
obj -= {'a', 'b'}
64656466
case.assertSetEqual(obj, {'c'})
64666467
case.assertIsInstance(obj, multiprocessing.managers.SetProxy)
6468+
64676469
obj.clear()
64686470
obj.update(['a', 'b', 'c'])
64696471
result = {'b', 'c', 'd'} ^ obj
@@ -6473,35 +6475,35 @@ def _test_set_operator_symbols(cls, obj):
64736475
obj ^= {'b', 'c', 'd'}
64746476
case.assertSetEqual(obj, {'a', 'd'})
64756477
case.assertIsInstance(obj, multiprocessing.managers.SetProxy)
6478+
64766479
obj.clear()
64776480
obj.update(['a', 'b', 'c'])
64786481
result = obj & {'b', 'c', 'd'}
64796482
case.assertSetEqual(result, {'b', 'c'})
64806483
result = {'b', 'c', 'd'} & obj
64816484
case.assertSetEqual(result, {'b', 'c'})
64826485
obj &= {'b', 'c', 'd'}
6483-
case.assertIsInstance(obj, multiprocessing.managers.SetProxy)
64846486
case.assertSetEqual(obj, {'b', 'c'})
6487+
case.assertIsInstance(obj, multiprocessing.managers.SetProxy)
6488+
64856489
obj.clear()
64866490
obj.update(['a', 'b', 'c'])
6487-
case.assertGreater(obj, {'a'})
6488-
case.assertGreaterEqual(obj, {'a', 'b'})
6489-
case.assertLess(obj, {'a', 'b', 'c', 'd'})
6490-
case.assertLessEqual(obj, {'a', 'b', 'c'})
6491-
case.assertSetEqual({o for o in obj}, {'a', 'b', 'c'})
6491+
case.assertSetEqual(set(obj), {'a', 'b', 'c'})
64926492

64936493
@classmethod
64946494
def _test_set_operator_methods(cls, obj):
64956495
case = unittest.TestCase()
64966496
obj.add('d')
64976497
case.assertIn('d', obj)
6498+
64986499
obj.clear()
64996500
obj.update(['a', 'b', 'c'])
65006501
copy_obj = obj.copy()
65016502
case.assertSetEqual(copy_obj, obj)
65026503
obj.remove('a')
65036504
case.assertNotIn('a', obj)
65046505
case.assertRaises(KeyError, obj.remove, 'a')
6506+
65056507
obj.clear()
65066508
obj.update(['a'])
65076509
obj.discard('a')
@@ -6511,18 +6513,21 @@ def _test_set_operator_methods(cls, obj):
65116513
obj.update(['a'])
65126514
popped = obj.pop()
65136515
case.assertNotIn(popped, obj)
6516+
65146517
obj.clear()
65156518
obj.update(['a', 'b', 'c'])
65166519
result = obj.intersection({'b', 'c', 'd'})
65176520
case.assertSetEqual(result, {'b', 'c'})
65186521
obj.intersection_update({'b', 'c', 'd'})
65196522
case.assertSetEqual(obj, {'b', 'c'})
6523+
65206524
obj.clear()
65216525
obj.update(['a', 'b', 'c'])
65226526
result = obj.difference({'a', 'b'})
65236527
case.assertSetEqual(result, {'c'})
65246528
obj.difference_update({'a', 'b'})
65256529
case.assertSetEqual(obj, {'c'})
6530+
65266531
obj.clear()
65276532
obj.update(['a', 'b', 'c'])
65286533
result = obj.symmetric_difference({'b', 'c', 'd'})
@@ -6531,7 +6536,7 @@ def _test_set_operator_methods(cls, obj):
65316536
case.assertSetEqual(obj, {'a', 'd'})
65326537

65336538
@classmethod
6534-
def _test_set_miscellaneous(cls, obj):
6539+
def _test_set_comparisons(cls, obj):
65356540
case = unittest.TestCase()
65366541
obj.update(['a', 'b', 'c'])
65376542
result = obj.union({'d', 'e'})
@@ -6542,14 +6547,18 @@ def _test_set_miscellaneous(cls, obj):
65426547
case.assertFalse(obj.issubset({'a', 'b'}))
65436548
case.assertTrue(obj.issuperset({'a', 'b'}))
65446549
case.assertFalse(obj.issuperset({'a', 'b', 'd'}))
6550+
case.assertGreater(obj, {'a'})
6551+
case.assertGreaterEqual(obj, {'a', 'b'})
6552+
case.assertLess(obj, {'a', 'b', 'c', 'd'})
6553+
case.assertLessEqual(obj, {'a', 'b', 'c'})
65456554

65466555
def test_set(self):
65476556
o = self.manager.set()
65486557
self.run_worker(self._test_set_operator_symbols, o)
65496558
o = self.manager.set()
65506559
self.run_worker(self._test_set_operator_methods, o)
65516560
o = self.manager.set()
6552-
self.run_worker(self._test_set_miscellaneous, o)
6561+
self.run_worker(self._test_set_comparisons, o)
65536562

65546563
def test_set_init(self):
65556564
o = self.manager.set({'a', 'b', 'c'})

0 commit comments

Comments
 (0)