mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-35477: multiprocessing.Pool.__enter__() fails if called twice (GH-11134)
multiprocessing.Pool.__enter__() now fails if the pool is not running: "with pool:" fails if used more than once.
This commit is contained in:
parent
502fe19b10
commit
08c2ba0717
3 changed files with 27 additions and 8 deletions
|
@ -2561,6 +2561,22 @@ class _TestPool(BaseTestCase):
|
|||
# they were released too.
|
||||
self.assertEqual(CountedObject.n_instances, 0)
|
||||
|
||||
def test_enter(self):
|
||||
if self.TYPE == 'manager':
|
||||
self.skipTest("test not applicable to manager")
|
||||
|
||||
pool = self.Pool(1)
|
||||
with pool:
|
||||
pass
|
||||
# call pool.terminate()
|
||||
# pool is no longer running
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
# bpo-35477: pool.__enter__() fails if the pool is not running
|
||||
with pool:
|
||||
pass
|
||||
pool.join()
|
||||
|
||||
|
||||
def raising():
|
||||
raise KeyError("key")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue