title: How to abort waiting for sys.stdin in python3?
body: <p>I'm running a script with two threads, a thread reading from a subprocess, and the main thread.</p>
  
  <p>inside the main thread, I'm reading from <code>stdin</code>, like so:</p>
  
  <pre><code>for line in sys.stdin:
  
      if proc.poll() != None:
          break
  
      proc.stdin.write(line)
      proc.stdin.flush()
  
      &lt;other things happen here&gt;
  </code></pre>
  
  <p><em>(<code>proc</code> is the external subprocess)</em></p>
  
  <p>Now, this works well, until I want to close my program. When the process in the other thread exits, I want the whole program to stop, but the main thread still waits for something to be entered into <code>stdin</code>. How can I abort that?</p>
  
  <p>Basically, I want <code>stdin</code> to be signaled an <code>EOF</code>, but I have no idea how to do that.</p>