Handle PermissionError in Windows CI

This commit is contained in:
richardpaulhudson 2022-10-04 12:12:09 +02:00
parent b48f2e1494
commit 522b0edc8c

View File

@ -218,15 +218,16 @@ def test_project_run_multiprocessing_failure(failing_command: str):
with a non-zero return code, the other two commands after several seconds with with a non-zero return code, the other two commands after several seconds with
zero return codes. Measuring the execution length for the whole group shows zero return codes. Measuring the execution length for the whole group shows
whether or not the sleeping processes were successfully terminated.""" whether or not the sleeping processes were successfully terminated."""
try:
with make_tempdir() as d: with make_tempdir() as d:
pscript = """ pscript = """
import sys import sys
from time import sleep from time import sleep
_, sleep_secs, rc = sys.argv _, sleep_secs, rc = sys.argv
sleep(int(sleep_secs)) sleep(int(sleep_secs))
sys.exit(int(rc)) sys.exit(int(rc))
""" """
pscript_loc = os.sep.join((str(d), "pscript.py")) pscript_loc = os.sep.join((str(d), "pscript.py"))
@ -267,9 +268,11 @@ sys.exit(int(rc))
else: else:
assert rc_e.value.code == 1 assert rc_e.value.code == 1
time_taken = time() - start time_taken = time() - start
print("time_taken:", time_taken)
assert ( assert (
time_taken < 15 time_taken < 15
), "Test took {time_taken}, subprocess seems not to have been terminated" ), "Test took {time_taken}, subprocess seems not to have been terminated"
except PermissionError: # occurs on Windows in the CI because the terminated subprocess still has
# a handle on the temporary directory
pass