mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +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
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
from test.support import (verbose, refcount_test, run_unittest,
|
||||
strip_python_stderr, cpython_only)
|
||||
strip_python_stderr, cpython_only, start_threads)
|
||||
from test.script_helper import assert_python_ok, make_script, temp_dir
|
||||
|
||||
import sys
|
||||
|
@ -397,19 +397,13 @@ class GCTests(unittest.TestCase):
|
|||
old_switchinterval = sys.getswitchinterval()
|
||||
sys.setswitchinterval(1e-5)
|
||||
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.setswitchinterval(old_switchinterval)
|
||||
gc.collect()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue