summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-08-16 18:53:28 (GMT)
committerGitHub <noreply@github.com>2017-08-16 18:53:28 (GMT)
commitee84a608587b930176d37303afae8a4358e15990 (patch)
treeaade6691a045b2dc375af1b1afa4c2dbc01e162c /Lib/test
parent17657bb9458ff8f8804b7637d61686a68f4b9471 (diff)
downloadcpython-ee84a608587b930176d37303afae8a4358e15990.zip
cpython-ee84a608587b930176d37303afae8a4358e15990.tar.gz
cpython-ee84a608587b930176d37303afae8a4358e15990.tar.bz2
bpo-18966: non-daemonic threads created by a multiprocessing.Process should be joined on exit (#3111)
* bpo-18966: non-daemonic threads created by a multiprocessing.Process should be joined on exit * Add NEWS blurb
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/_test_multiprocessing.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index dce62df..d6fe7d6 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -542,6 +542,32 @@ class _TestProcess(BaseTestCase):
p.join()
close_queue(q)
+ @classmethod
+ def _test_wait_for_threads(self, evt):
+ def func1():
+ time.sleep(0.5)
+ evt.set()
+
+ def func2():
+ time.sleep(20)
+ evt.clear()
+
+ threading.Thread(target=func1).start()
+ threading.Thread(target=func2, daemon=True).start()
+
+ def test_wait_for_threads(self):
+ # A child process should wait for non-daemonic threads to end
+ # before exiting
+ if self.TYPE == 'threads':
+ self.skipTest('test not appropriate for {}'.format(self.TYPE))
+
+ evt = self.Event()
+ proc = self.Process(target=self._test_wait_for_threads, args=(evt,))
+ proc.start()
+ proc.join()
+ self.assertTrue(evt.is_set())
+
+
#
#
#