diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-20 21:29:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-20 21:29:37 (GMT) |
commit | efb60c0ceba425dc2bc602f615a75271f264e0a2 (patch) | |
tree | 2adfe37ac6041184dc938525187e90b47fb4335d /Lib/test | |
parent | a7a52ab7ee58be0afca3a7763fffc928dcf5459d (diff) | |
download | cpython-efb60c0ceba425dc2bc602f615a75271f264e0a2.zip cpython-efb60c0ceba425dc2bc602f615a75271f264e0a2.tar.gz cpython-efb60c0ceba425dc2bc602f615a75271f264e0a2.tar.bz2 |
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.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index ba60d8a..6723d00 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -306,6 +306,30 @@ 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, "Woke up, sleep function is: <built-in function sleep>\n") + self.assertEqual(stderr, "") + + def test_enumerate_after_join(self): # Try hard to trigger #1703448: a thread is still returned in |