Issue #23799: Added test.test_support.start_threads() for running and
cleaning up multiple threads.
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index 5746c39..ed01c98 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1,5 +1,5 @@
import unittest
-from test.test_support import verbose, run_unittest
+from test.test_support import verbose, run_unittest, start_threads
import sys
import time
import gc
@@ -352,19 +352,13 @@
old_checkinterval = sys.getcheckinterval()
sys.setcheckinterval(3)
try:
- exit = False
+ exit = []
threads = []
for i in range(N_THREADS):
t = threading.Thread(target=run_thread)
threads.append(t)
- try:
- for t in threads:
- t.start()
- finally:
+ with start_threads(threads, lambda: exit.append(1)):
time.sleep(1.0)
- exit = True
- for t in threads:
- t.join()
finally:
sys.setcheckinterval(old_checkinterval)
gc.collect()