human
I wrote the below code

    def assert_gone(pid):
        assert (not psutil.pid_exists(pid)), pid
        assert (pid not in psutil.pids()), pid
        try:
            p = psutil.Process(pid)
            assert (not p.is_running()), pid
        except psutil.NoSuchProcess:
            pass
        else:
            assert 0, ('pid    %s    is    not    gone' % pid)
    if recursive:
        children = set(psutil.Process().children(recursive=True))
    else:
        children = set()
    while _subprocesses_started:
        subp = _subprocesses_started.pop()
        _pids_started.add(subp.pid)
        try:
            subp.terminate()
        except OSError as err:
            if (err.errno != errno.ESRCH):
                raise
        if subp.stdout:
            subp.stdout.close()
        if subp.stderr:
            subp.stderr.close()
        try:
            if subp.stdin:
                subp.stdin.close()
        finally:
            try:
                subp.wait()
            except OSError as err:
                if (err.errno != errno.ECHILD):
                    raise
    while _pids_started:
        pid = _pids_started.pop()
        try:
            p = psutil.Process(pid)
        except psutil.NoSuchProcess:
            assert_gone(pid)
        else:
            children.add(p)
    if children:
        for p in children:
            try:
                p.terminate()
            except psutil.NoSuchProcess:
                pass
        (gone, alive) = psutil.wait_procs(children, timeout=GLOBAL_TIMEOUT)
        for p in alive:
            warn(("couldn't    terminate    process    %r.
   attempting    kill()" % p))
            try:
                p.kill()
            except psutil.NoSuchProcess:
                pass
        (gone, alive) = psutil.wait_procs(alive, timeout=GLOBAL_TIMEOUT)
        if alive:
            for p in alive:
                warn(('process    %r    survived    kill()' % p))
        for p in children:
            assert_gone(p.pid)

What's a good function header?
assistant
#Here's a good function header.

def reap_children(recursive=False):