summaryrefslogtreecommitdiff
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index c7a22130e9..1e1e625083 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -286,6 +286,29 @@ 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")
+ stderr = re.sub(br"^\[\d+ refs\]", b"", stderr, re.MULTILINE).strip()
+ self.assertEqual(stderr, b"")
def test_enumerate_after_join(self):
# Try hard to trigger #1703448: a thread is still returned in