2020-08-05 10:43:35 +00:00
|
|
|
"""Util to handle processes."""
|
|
|
|
|
2021-01-18 21:23:25 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2020-08-05 10:43:35 +00:00
|
|
|
import subprocess
|
2021-01-18 21:23:25 +00:00
|
|
|
from typing import Any
|
|
|
|
|
2020-08-05 10:43:35 +00:00
|
|
|
|
2022-01-11 12:41:57 +00:00
|
|
|
def kill_subprocess(process: subprocess.Popen[Any]) -> None:
|
2020-08-05 10:43:35 +00:00
|
|
|
"""Force kill a subprocess and wait for it to exit."""
|
|
|
|
process.kill()
|
|
|
|
process.communicate()
|
|
|
|
process.wait()
|
|
|
|
|
|
|
|
del process
|