summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_concurrent_futures.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-07-04 11:14:04 (GMT)
committerGitHub <noreply@github.com>2017-07-04 11:14:04 (GMT)
commit3df9dec425b0254df1cdf41922fd8d6b08bf47e4 (patch)
treecc5165b34102dbdbe616f0e8f78516e7fa8deeb5 /Lib/test/test_concurrent_futures.py
parent48350412b70c76fa51f488cfc736c80d59b5e8eb (diff)
downloadcpython-3df9dec425b0254df1cdf41922fd8d6b08bf47e4.zip
cpython-3df9dec425b0254df1cdf41922fd8d6b08bf47e4.tar.gz
cpython-3df9dec425b0254df1cdf41922fd8d6b08bf47e4.tar.bz2
bpo-30845: Enhance test_concurrent_futures cleanup (#2564)
* bpo-30845: reap_children() now logs warnings * bpo-30845: Enhance test_concurrent_futures cleanup In setUp() and tearDown() methods of test_concurrent_futures tests, make sure that tests don't leak threads nor processes. Clear explicitly the reference to the executor to make it that it's destroyed (to prevent "dangling threads" warning).
Diffstat (limited to 'Lib/test/test_concurrent_futures.py')
-rw-r--r--Lib/test/test_concurrent_futures.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index e2da47b..c649555 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -63,6 +63,8 @@ class ExecutorMixin:
worker_count = 5
def setUp(self):
+ self._thread_cleanup = test.support.threading_setup()
+
self.t1 = time.time()
try:
self.executor = self.executor_type(max_workers=self.worker_count)
@@ -72,11 +74,16 @@ class ExecutorMixin:
def tearDown(self):
self.executor.shutdown(wait=True)
+ self.executor = None
+
dt = time.time() - self.t1
if test.support.verbose:
print("%.2fs" % dt, end=' ')
self.assertLess(dt, 60, "synchronization issue: test lasted too long")
+ test.support.threading_cleanup(*self._thread_cleanup)
+ test.support.reap_children()
+
def _prime_executor(self):
# Make sure that the executor is ready to do work before running the
# tests. This should reduce the probability of timeouts in the tests.