def kill_gracefully(process, timeout=2):
    try:
        with suppress(ProcessLookupError):
            process.terminate()
        stdout, stderr = process.communicate(timeout=timeout)

    except subprocess.TimeoutExpired:
        _, stdout, stderr = kill_hard(process)

    return process.returncode, stdout, stderr
Open the input file in a Python interpreter.
dataset/ETHPy150Open box/ClusterRunner/app/util/process_utils.py/kill_gracefully--crossover with--dataset/ETHPy150Open mapbox/rasterio/rasterio/rio/insp.py/insp