Skip to content

Commit 8550c29

Browse files
committed
Restore the old trace function at the end to make regrtest happy.
1 parent 3a10fe2 commit 8550c29

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/test/test_threading.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,17 +1043,21 @@ def checker():
10431043
def test_settrace_all_threads_race(self):
10441044
# GH-132296: settrace_all_threads() could be racy on the free-threaded build
10451045
#if the threads were concurrently deleted.
1046+
old_trace = threading.gettrace()
10461047
def dummy(*args):
10471048
pass
10481049

10491050
def do_settrace():
10501051
threading.settrace_all_threads(dummy)
10511052

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
1053+
try:
1054+
with threading_helper.catch_threading_exception() as cm:
1055+
with threading_helper.start_threads((threading.Thread(target=do_settrace) for _ in range(8))):
1056+
pass
10551057

1056-
self.assertIsNone(cm.exc_value)
1058+
self.assertIsNone(cm.exc_value)
1059+
finally:
1060+
threading.settrace_all_threads(old_trace)
10571061

10581062
def test_getprofile(self):
10591063
def fn(*args): pass

0 commit comments

Comments
 (0)