It seems like the new regrtest design doesn't work as I expected.
Calling popen.kill() + popen.stdout.close() + popen.stderr.close() from a thread B does not always interrupt popen.communicate() in thread A.
See https://bugs.python.org/issue38207#msg352729 for an example on Linux where communicate() still blocks until all child processes complete.
I see different options:
* Revert changes to restore regrtest old design which didn't have these new issues
* Find a way to fix bpo-38207 on all platforms: be able to interrupt communicate() as soon as the process is killed and/or when all pipes are closed.
* Call communicate() with shorter timeout to workaround the blocking communicate() issue (bpo-38207).
* Maybe experiment asyncio which supports asynchronous subprocess.
asyncio subprocess uses overlapped operations which can be cancelled. So maybe it isn't affected by bpo-38207. |