Skip to content

Commit 52896bc

Browse files
committed
Add a test case.
1 parent 280f79c commit 52896bc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Lib/test/test_threading.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,23 @@ def modify_file():
18871887
t.start()
18881888
t.join()
18891889

1890+
def test_dummy_thread_on_interpreter_shutdown(self):
1891+
# GH-130522: When `threading` held a reference to itself and then a
1892+
# _DummyThread() object was created, destruction of the dummy thread
1893+
# would emit an unraisable exception at shutdown, due to a lock being
1894+
# destroyed.
1895+
code = """if True:
1896+
import sys
1897+
import threading
1898+
1899+
threading.x = sys.modules[__name__]
1900+
x = threading._DummyThread()
1901+
"""
1902+
rc, out, err = assert_python_ok("-c", code)
1903+
self.assertEqual(rc, 0)
1904+
self.assertEqual(out, b"")
1905+
self.assertEqual(err, b"")
1906+
18901907

18911908
class ThreadRunFail(threading.Thread):
18921909
def run(self):

0 commit comments

Comments
 (0)