process_utils
process_utils
¶
Subprocess helpers with hard timeout and process-tree cleanup.
Functions:¶
run_with_timeout
¶
run_with_timeout(
args: str | Sequence[str],
*,
timeout: float,
shell: bool = False,
cwd: str | Path | None = None,
env: Mapping[str, str] | None = None,
) -> CompletedProcess[str]
Run a command and kill its process group if the deadline expires.
subprocess.run(timeout=...) kills only the immediate child. Starting a
new session on POSIX lets Diapason terminate the whole process group, so a
timed-out shell command cannot leave grandchildren running in background.