INNER CODE UNIT · Python

terminate_running_process

ChenShuo2004/cs-board · webapp/server.py:513

def terminate_running_process(job_id: str) -> None:
    with RUNNING_PROCESSES_LOCK:
        process = RUNNING_PROCESSES.get(job_id)
    if process is None or process.poll() is not None:
        return
    try:
        if os.name == "nt":
            subprocess.run(
                ["taskkill", "/PID", str(process.pid), "/T", "/F"],
                capture_output=True,
                text=True,
                timeout=8,
                check=False,
            )
        else:
            process.terminate()
    except (OSError, subprocess.SubprocessError):
        try:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…