title: How to run a process with timeout and still get stdout at runtime
body: <p>The need:</p>
  
  <ol>
  <li>Timeout after X seconds, and kill the process (and all the processes it opened) if timeout reached before the process ends gracefully.</li>
  <li>Read ongoing output at runtime.</li>
  <li>Work with processes that produce output, ones that don't, and ones that produce output, and then stop producing it (e.g. get
  stuck).</li>
  <li>Run on Windows.</li>
  <li>Run on Python 3.5.2.</li>
  </ol>
  
  <p>Python 3 subprocess module has <a href="https://docs.python.org/3/library/subprocess.html#subprocess.TimeoutExpired.timeout">timeout</a> built in, and I've also tried and implemented timeout myself using timer and using threads, but it doesn't work with the output. <code>readline()</code> is blocking or not? <code>readlines()</code> is definitely waiting for the process to end before spitting out all the output, which is not what I need (I need ongoing).</p>
  
  <p>I am close to switching to node.js :-(</p>