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