(command, timeout)
return True
call shell-command and either return its output or kill it
    if it doesn't normally exit within timeout seconds and return None
call shell-command and either return its output or kill it
    if it doesn't normally exit within timeout seconds and return None
call shell - command and either return its output or kill it if it doesn t normally exit within timeout seconds and return None
def timeout_command(command, timeout):
    """call shell-command and either return its output or kill it
    if it doesn't normally exit within timeout seconds and return None"""
    import subprocess, datetime, os, time, signal
    start = datetime.datetime.now()
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    while process.poll() is None:
        time.sleep(0.1)
        now = datetime.datetime.now()
        if (now - start).seconds > timeout:
            os.kill(process.pid, signal.SIGKILL)
            os.waitpid(-1, os.WNOHANG)
            return False
    return True
def timeout_command ( command , timeout ) : import subprocess , datetime , os , time , signal start = datetime . datetime . now ( ) process = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) while process . poll ( ) is None : time . sleep ( 0.1 ) now = datetime . datetime . now ( ) if ( now - start ) . seconds > timeout : os . kill ( process . pid , signal . SIGKILL ) os . waitpid ( - 1 , os . WNOHANG ) return False return True