summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-10-20 21:52:47 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-10-20 21:52:47 (GMT)
commit011bd62c8ca1888e04e579a4dac3dcc103e9a74b (patch)
treec3844c0c8d0f884be1e5c579ac1130d89978c77b /Lib/test
parent06bb6746ed6151403e678fee8a37e8c90b9791ea (diff)
downloadcpython-011bd62c8ca1888e04e579a4dac3dcc103e9a74b.zip
cpython-011bd62c8ca1888e04e579a4dac3dcc103e9a74b.tar.gz
cpython-011bd62c8ca1888e04e579a4dac3dcc103e9a74b.tar.bz2
Merged revisions 75570 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75570 | antoine.pitrou | 2009-10-20 23:29:37 +0200 (mar., 20 oct. 2009) | 6 lines Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which fixes the problem of some exceptions being thrown at shutdown when the interpreter is killed. Patch by Adam Olsen. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_threading.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 8ce480e..2e4f645 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -300,6 +300,28 @@ class ThreadTests(unittest.TestCase):
self.assertFalse(rc == 2, "interpreted was blocked")
self.assertTrue(rc == 0, "Unexpected error")
+ def test_join_nondaemon_on_shutdown(self):
+ # Issue 1722344
+ # Raising SystemExit skipped threading._shutdown
+ import subprocess
+ p = subprocess.Popen([sys.executable, "-c", """if 1:
+ import threading
+ from time import sleep
+
+ def child():
+ sleep(1)
+ # As a non-daemon thread we SHOULD wake up and nothing
+ # should be torn down yet
+ print("Woke up, sleep function is:", sleep)
+
+ threading.Thread(target=child).start()
+ raise SystemExit
+ """],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ self.assertEqual(stdout, b"Woke up, sleep function is: <built-in function sleep>\n")
+ self.assertEqual(stderr, b"")
def test_enumerate_after_join(self):
# Try hard to trigger #1703448: a thread is still returned in