close() on child subprocesses is causing ValueErrors on Python 3.7+

Summary

We already have the issue where Process.close() is new api for 3.7 onwards !1773 (closed) . However, when using 3.7 close() raises a ValueError exception if the process has not finished running beforehand (or joined) https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.Process.close

I'm not sure we want to join here with any blocking timeout. This changes was introduced with 9c23ce5c

Steps to reproduce

Attempt to track or build the debian synthetic target, the console will be filled with the exceptions due to so many rapidly executing child jobs, with the exceptions being handled by the event loops default handler which in turn means that python doesn't bail out.

What is the expected correct behavior?

We should not be trying to close running or non-joined processes, leading to no exceptions.

Relevant logs and/or screenshots

$1923566

Possible fixes

Revert the change to using close(), which would also rectify the python version issue. Potentially add an exception handler to the event loop, ensuring exceptions like this are re-raised & are as such unhandled & rightly bugs.


Edited by Tom Pollard