Call a subprocess with a timeout.
Like subprocess.check_call(), but will terminate the process and raise TimeoutError if it runs for too long.
This will only terminate the single process started; any child processes will remain running (this has implications for, say, spawing shells.)
Parameters: | timeout : float
args : sequence
kwargs : dict
|
---|---|
Returns: | out : int
|
Raises: | TimeoutError : If subprocess does not return in timeout seconds. CalledProcessError : if command has non-zero exit status |
Examples
>>> import spacepy.toolbox as tb
>>> tb.timeout_check_call(1, 'sleep 30', shell=True) #raises TimeoutError