Skip to content

bpo-30845: Enhance test_concurrent_futures cleanup #2564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,6 @@ def reap_children():
stick around to hog resources and create problems when looking
for refleaks.
"""

# Reap all our dead child processes so we don't leave zombies around.
# These hog resources and might be causing some of the buildbots to die.
if hasattr(os, 'waitpid'):
Expand All @@ -2090,6 +2089,8 @@ def reap_children():
pid, status = os.waitpid(any_process, os.WNOHANG)
if pid == 0:
break
print("Warning -- reap_children() reaped child process %s"
% pid, file=sys.stderr)
except:
break

Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_concurrent_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -72,11 +74,16 @@ def setUp(self):

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.
Expand Down