summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_gc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-01 10:01:14 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-01 10:01:14 (GMT)
commit263dcd20a374d540c8f0bc07332f1657adf6da83 (patch)
treec44955a3ff494353583163d4634cae512e7836dc /Lib/test/test_gc.py
parent8218bd4caf683ee98c450a093bf171dbca6c4849 (diff)
downloadcpython-263dcd20a374d540c8f0bc07332f1657adf6da83.zip
cpython-263dcd20a374d540c8f0bc07332f1657adf6da83.tar.gz
cpython-263dcd20a374d540c8f0bc07332f1657adf6da83.tar.bz2
Issue #23799: Added test.support.start_threads() for running and cleaning up
multiple threads.
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r--Lib/test/test_gc.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index c025512..2ac1d4b 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -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()