mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #23799: Added test.support.start_threads() for running and cleaning up
multiple threads.
This commit is contained in:
parent
8218bd4caf
commit
263dcd20a3
9 changed files with 77 additions and 80 deletions
|
@ -14,7 +14,7 @@ import shutil
|
|||
import unittest
|
||||
from test.support import (
|
||||
verbose, import_module, run_unittest, TESTFN, reap_threads,
|
||||
forget, unlink, rmtree)
|
||||
forget, unlink, rmtree, start_threads)
|
||||
threading = import_module('threading')
|
||||
|
||||
def task(N, done, done_tasks, errors):
|
||||
|
@ -115,10 +115,10 @@ class ThreadedImportTests(unittest.TestCase):
|
|||
errors = []
|
||||
done_tasks = []
|
||||
done.clear()
|
||||
for i in range(N):
|
||||
t = threading.Thread(target=task,
|
||||
args=(N, done, done_tasks, errors,))
|
||||
t.start()
|
||||
with start_threads(threading.Thread(target=task,
|
||||
args=(N, done, done_tasks, errors,))
|
||||
for i in range(N)):
|
||||
pass
|
||||
self.assertTrue(done.wait(60))
|
||||
self.assertFalse(errors)
|
||||
if verbose:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue