diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-07-03 09:10:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 09:10:30 (GMT) |
commit | 684cb47fffb7af3ac50cb077f6d2a095c9ce20b4 (patch) | |
tree | b71744c721a70441af55fdb27dbddd4e58ed2e62 /Lib | |
parent | b71d8d67959f3b5efbdfe00066589ac0d8f98aad (diff) | |
download | cpython-684cb47fffb7af3ac50cb077f6d2a095c9ce20b4.zip cpython-684cb47fffb7af3ac50cb077f6d2a095c9ce20b4.tar.gz cpython-684cb47fffb7af3ac50cb077f6d2a095c9ce20b4.tar.bz2 |
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().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_concurrent_futures.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 2497c2b..c782d4c 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -27,6 +27,9 @@ from concurrent.futures._base import ( from concurrent.futures.process import BrokenProcessPool from multiprocessing import get_context +import multiprocessing.process +import multiprocessing.util + def create_future(state=PENDING, exception=None, result=None): f = Future() @@ -1293,12 +1296,24 @@ class FutureTests(BaseTestCase): self.assertEqual(f.exception(), e) -@test.support.reap_threads -def test_main(): - try: - test.support.run_unittest(__name__) - finally: - test.support.reap_children() +_threads_key = None + +def setUpModule(): + global _threads_key + _threads_key = test.support.threading_setup() + + +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__": - test_main() + unittest.main() |