summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-12-13 01:15:30 (GMT)
committerGitHub <noreply@github.com>2018-12-13 01:15:30 (GMT)
commit08c2ba0717089662132af69bf5948d82277a8a69 (patch)
tree65536d44e81385773a0a4eaf4b047b6b3ab3575a /Lib/test/_test_multiprocessing.py
parent502fe19b10f66235fcf8f13fc1c0308190845def (diff)
downloadcpython-08c2ba0717089662132af69bf5948d82277a8a69.zip
cpython-08c2ba0717089662132af69bf5948d82277a8a69.tar.gz
cpython-08c2ba0717089662132af69bf5948d82277a8a69.tar.bz2
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.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 0b0fe7c..a2dc53c 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -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")