kaitiaki.terminal
Functions
|
Executes a terminal command. |
|
Okay, this one deserves an explanation. |
Module Contents
- kaitiaki.terminal.execute(command, timeout=5 * 60, cwd=None, warn=True)
Executes a terminal command.
Has a default timeout period of 5 minutes.
- Parameters:
execute. (command {string} -- The command to)
- Keyword Arguments:
time (timeout {int} -- The)
(default (should execute for at most.) – {5*60})
- Returns:
tuple – A 3-tuple representing (stdout, stderr, reason for termination)
- kaitiaki.terminal._custom_subprocess_handler(command, timeout=5 * 60, cwd=None)
Okay, this one deserves an explanation.
I noticed that for jobs that took longer than timeout seconds to run, they wouldn’t be killed correctly. See the following SO post that I made:
So what I ended up finding out is that Python treats subprocesses which spawn groups weirdly. STARS, I suppose, does such a thing. Essentially, the SIGKILL signal gets sent to the subprocess – but not the group. In turn, this means that the subprocesses that do spawn groups don’t get killed when a TimeoutException is thrown. So, what follows is a copy of the Python source code, with the group-killer added (see “the magic line!” below).
© original author. Modified on 06 May 2022 by Sean Richards (@Krytic).