def _terminate_processes() -> None:
    "Kill all spawned processes.\n\n    Processes to be killed must be appended to `utils.processes_to_kill`\n    as they are spawned.\n\n    An important caveat: since there's no supported way to kill another\n    thread in Python, this function cannot stop other threads from\n    continuing to execute while it kills the processes that they've\n    spawned. This may occasionally lead to unexpected behaviour.\n    "
    while processes_to_kill:
        process = processes_to_kill.popleft()
        if isinstance(process.args, MutableSequence):
            args = process.args
        else:
            args = [process.args]
        cidfile = [str(arg).split('=')[1] for arg in args if ('--cidfile' in str(arg))]
        if cidfile:
            try:
                with open(cidfile[0]) as inp_stream:
                    p = subprocess.Popen(['docker', 'kill', inp_stream.read()], shell=False)
                    try:
                        p.wait(timeout=10)
                    except subprocess.TimeoutExpired:
                        p.kill()
            except FileNotFoundError:
                pass
        if process.stdin:
            process.stdin.close()
        try:
            process.wait(10)
        except subprocess.TimeoutExpired:
            pass
        process.kill()
Kill all spawned processes.

Processes to be killed must be appended to `utils.processes_to_kill`
as they are spawned.

An important caveat: since there's no supported way to kill another
thread in Python, this function cannot stop other threads from
continuing to execute while it kills the processes that they've
spawned. This may occasionally lead to unexpected behaviour.
def _terminate_processes() -> None:
    "Kill all spawned processes.\n\n    Processes to be killed must be appended to `utils.processes_to_kill`\n    as they are spawned.\n\n    An important caveat: since there's no supported way to kill another\n    thread in Python, this function cannot stop other threads from\n    continuing to execute while it kills the processes that they've\n    spawned. This may occasionally lead to unexpected behaviour.\n    "
    while processes_to_kill:
        process = processes_to_kill.popleft()
        if isinstance(process.args, MutableSequence):
            args = process.args
        else:
            args = [process.args]
        cidfile = [str(arg).split('=')[1] for arg in args if ('--cidfile' in str(arg))]
        if cidfile:
            try:
                with open(cidfile[0]) as inp_stream:
                    p = subprocess.Popen(['docker', 'kill', inp_stream.read()], shell=False)
                    try:
                        p.wait(timeout=10)
                    except subprocess.TimeoutExpired:
                        p.kill()
            except FileNotFoundError:
                pass
        if process.stdin:
            process.stdin.close()
        try:
            process.wait(10)
        except subprocess.TimeoutExpired:
            pass
        process.kill()