Issue #23799: Added test.support.start_threads() for running and cleaning up
multiple threads.
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index ba7c38d..36c62376 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -202,15 +202,11 @@
context.lock = threading.Lock()
context.event = threading.Event()
- for i in range(context.nThreads):
- t = threading.Thread(target=self.pendingcalls_thread, args = (context,))
- t.start()
- threads.append(t)
-
- self.pendingcalls_wait(context.l, n, context)
-
- for t in threads:
- t.join()
+ threads = [threading.Thread(target=self.pendingcalls_thread,
+ args=(context,))
+ for i in range(context.nThreads)]
+ with support.start_threads(threads):
+ self.pendingcalls_wait(context.l, n, context)
def pendingcalls_thread(self, context):
try: