mirror of
https://github.com/python/cpython.git
synced 2025-10-03 13:45:29 +00:00
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().
(cherry picked from commit 684cb47fff
)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
parent
a2a807f75d
commit
79665c698f
2 changed files with 24 additions and 7 deletions
|
@ -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()
|
||||||
|
@ -1294,12 +1297,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()
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
test_concurrent_futures now cleans up multiprocessing to remove immediately
|
||||||
|
temporary directories created by multiprocessing.util.get_temp_dir().
|
Loading…
Add table
Add a link
Reference in a new issue