mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +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().
This commit is contained in:
parent
b71d8d6795
commit
684cb47fff
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 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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue