Skip to content

Commit 136f4d8

Browse files
committed
Add a test.
1 parent 0a9bbfa commit 136f4d8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_threading.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,22 @@ def checker():
10391039
self.assertEqual(threading.gettrace(), old_trace)
10401040
self.assertEqual(sys.gettrace(), old_trace)
10411041

1042+
@unittest.skipUnless(support.Py_GIL_DISABLED, "only meaningful under free-threading")
1043+
def test_settrace_all_threads_race(self):
1044+
# GH-132296: settrace_all_threads() could be racy on the free-threaded build
1045+
#if the threads were concurrently deleted.
1046+
def dummy(*args):
1047+
pass
1048+
1049+
def do_settrace():
1050+
threading.settrace_all_threads(dummy)
1051+
1052+
with threading_helper.catch_threading_exception() as cm:
1053+
with threading_helper.start_threads((threading.Thread(target=do_settrace) for _ in range(8))):
1054+
pass
1055+
1056+
self.assertIsNone(cm.exc_value)
1057+
10421058
def test_getprofile(self):
10431059
def fn(*args): pass
10441060
old_profile = threading.getprofile()

0 commit comments

Comments
 (0)