class Timeout(Exception):
    pass

def run(command, timeout=10):
    proc = subprocess.Popen(command, bufsize=0, stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
poll_seconds = 0.25
deadline = time.time() + timeout
while time.time() < deadline and proc.poll() == None:
    time.sleep(poll_seconds)
if proc.poll() == None:
    pass
python: run a process with timeout and capture stdout, stderr and exit status