Possible Duplicate:
subprocess with timeout
What is the easiest way to do the following in Python:
- Run an external process
- Capture stdout in a string, stderr, and exit status
- Set a timeout.
I would like something like this:
import proc
try:
status, stdout, stderr = proc.run(["ls", "-l"], timeout=10)
except proc.Timeout:
print "failed"