Find execution time for subprocess.Popen python

Viewed 6160

Here's the Python code to run an arbitrary command returning its stdout data, or raise an exception on non-zero exit codes:

proc = subprocess.Popen(
cmd,
stderr=subprocess.STDOUT,  # Merge stdout and stderr 
stdout=subprocess.PIPE,
shell=True)

The subprocess module does not support execution-time and if it exceeds specific threshold => timeout(ability to kill a process running for more than X number of seconds)

What is the simplest way to implement get_execution_time and timeout in Python2.6 program meant to run on Linux?

1 Answers
Related