diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-14 13:49:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-14 13:49:16 (GMT) |
commit | 3c93153f7db5dd9b06f229e61978fd9199b3c097 (patch) | |
tree | b25667f4b3502b66fcd74aa98e5661da01fd2fa0 /Lib/test/libregrtest/runtest_mp.py | |
parent | 2bc158fefe89db8dfdd6d03ae6b3f2caa2f0cd6c (diff) | |
download | cpython-3c93153f7db5dd9b06f229e61978fd9199b3c097.zip cpython-3c93153f7db5dd9b06f229e61978fd9199b3c097.tar.gz cpython-3c93153f7db5dd9b06f229e61978fd9199b3c097.tar.bz2 |
bpo-36915: regrtest always remove tempdir of worker processes (GH-13312)
When using multiprocessing (-jN option), worker processes now create
their temporary directory inside the temporary directory of the
main process. So the main process is able to remove temporary
directories of worker processes even if they crash or when they are
killed by regrtest on KeyboardInterrupt (CTRL+c).
Rework also how multiprocessing arguments are parsed in main.py.
Diffstat (limited to 'Lib/test/libregrtest/runtest_mp.py')
-rw-r--r-- | Lib/test/libregrtest/runtest_mp.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py index 4217847..aa2409b 100644 --- a/Lib/test/libregrtest/runtest_mp.py +++ b/Lib/test/libregrtest/runtest_mp.py @@ -33,6 +33,12 @@ def must_stop(result, ns): return False +def parse_worker_args(worker_args): + ns_dict, test_name = json.loads(worker_args) + ns = types.SimpleNamespace(**ns_dict) + return (ns, test_name) + + def run_test_in_subprocess(testname, ns): ns_dict = vars(ns) worker_args = (ns_dict, testname) @@ -42,8 +48,6 @@ def run_test_in_subprocess(testname, ns): '-u', # Unbuffered stdout and stderr '-m', 'test.regrtest', '--worker-args', worker_args] - if ns.pgo: - cmd += ['--pgo'] # Running the child from the same working directory as regrtest's original # invocation ensures that TEMPDIR for the child is the same when @@ -56,15 +60,15 @@ def run_test_in_subprocess(testname, ns): cwd=support.SAVEDCWD) -def run_tests_worker(worker_args): - ns_dict, testname = json.loads(worker_args) - ns = types.SimpleNamespace(**ns_dict) - +def run_tests_worker(ns, test_name): setup_tests(ns) - result = runtest(ns, testname) + result = runtest(ns, test_name) + print() # Force a newline (just in case) - print(json.dumps(result), flush=True) + + # Serialize TestResult as list in JSON + print(json.dumps(list(result)), flush=True) sys.exit(0) |