def run_with_timeout(timeout, args, kill_signal, kill_after=None,
                     cwd=None, kill_tree=True):
    p = subprocess.Popen(args, shell=False, cwd=cwd)

    finished = _run_with_timeout(p, timeout, kill_signal, kill_tree)
    if not finished:
        if kill_after:
            _run_with_timeout(p, kill_after, signal.SIGKILL, kill_tree)
    return p.returncode if finished else 124
Run a command with a timeout after which it will be forcibly killed.
dataset/ETHPy150Open Khan/alertlib/timeout.py/run_with_timeout