Commit 684cb47f authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-37421: test_concurrent_futures cleans up multiprocessing (GH-14563)

test_concurrent_futures now cleans up multiprocessing to remove
immediately temporary directories created by
multiprocessing.util.get_temp_dir().

The test now uses setUpModule() and tearDownModule().
parent b71d8d67
...@@ -27,6 +27,9 @@ from concurrent.futures._base import ( ...@@ -27,6 +27,9 @@ from concurrent.futures._base import (
from concurrent.futures.process import BrokenProcessPool from concurrent.futures.process import BrokenProcessPool
from multiprocessing import get_context from multiprocessing import get_context
import multiprocessing.process
import multiprocessing.util
def create_future(state=PENDING, exception=None, result=None): def create_future(state=PENDING, exception=None, result=None):
f = Future() f = Future()
...@@ -1293,12 +1296,24 @@ class FutureTests(BaseTestCase): ...@@ -1293,12 +1296,24 @@ class FutureTests(BaseTestCase):
self.assertEqual(f.exception(), e) self.assertEqual(f.exception(), e)
@test.support.reap_threads _threads_key = None
def test_main():
try: def setUpModule():
test.support.run_unittest(__name__) global _threads_key
finally: _threads_key = test.support.threading_setup()
test.support.reap_children()
def tearDownModule():
test.support.threading_cleanup(*_threads_key)
test.support.reap_children()
# cleanup multiprocessing
multiprocessing.process._cleanup()
# bpo-37421: Explicitly call _run_finalizers() to remove immediately
# temporary directories created by multiprocessing.util.get_temp_dir().
multiprocessing.util._run_finalizers()
test.support.gc_collect()
if __name__ == "__main__": if __name__ == "__main__":
test_main() unittest.main()
test_concurrent_futures now cleans up multiprocessing to remove immediately
temporary directories created by multiprocessing.util.get_temp_dir().
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment