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:
commit
c05e260ecb
9 changed files with 75 additions and 78 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):
|
||||
|
@ -116,10 +116,10 @@ class ThreadedImportTests(unittest.TestCase):
|
|||
done_tasks = []
|
||||
done.clear()
|
||||
t0 = time.monotonic()
|
||||
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
|
||||
completed = done.wait(10 * 60)
|
||||
dt = time.monotonic() - t0
|
||||
if verbose:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue