mtest: improve interrupting tests on Win32 #14311
Open
+42
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Interrupting tests on Windows is a bit of a mess right now: instead of
cleanly shutting down, Meson tends to send you heaps of exceptions of
various kinds. This seems to stem from the fact that on Windows, asyncio
does not properly support handling of signals, and thus we don't install
any signal handlers at all that would allow us to shut down the test
processes.
Work around the issue by using the low-level
run_until_complete()
function instead of
asyncio.run()
. This low-level function does notperform the same level of careful teardown, but due to that it also
causes us to not spew out heaps of errors.
We should likely roll back these changes if asyncio ever was to gain
support for proper signal handling, or if we were able to ever address
all of the exceptions. But until then, allowing for a clean shutdown
that doesn't overwhelm the user with errors feels preferable.
I'm not hugely familiar with asyncio, so I would very much ask you to be extra critical of the approach chosen in this PR. It works for me on Windows and I do see clean shutdown. One omission is that tests that have been cancelled do not get marked accordingly anymore, but first I'd like to get some feedback on the current approach before trying to fix that.