I have a long running process (k8s job with logs) that I wish to run via subprocess.check_output
. I only care about the output of the command in the first 60 seconds, so I've done this:
out = subprocess.check_output(
shlex.split(command),
timeout=60,
)
However, since the process runs for longer it ends with this exception. raise TimeoutExpired( subprocess.TimeoutExpired: Command ...
. Is there a way to simply terminate the command at 60 seconds and capture the output. The output is important as I wish to do some post processing of the output in the first 60 seconds.