title: Broken pipe during a subprocess stdin.write
body: <p>I interact with a server that I use to tag sentences. This server is launched locally on port <code>2020</code>.</p>
  
  <p>For example, if I send <code>Je mange des pâtes .</code> on port <code>2020</code> through the client used below, the server answers <code>Je_CL mange_V des_P pâtes_N ._.</code>, the result is always one line only, and always one line if my input is not empty.</p>
  
  <p>I currently have to tag 9 568 files through this server. The first 9 483 files are tagged as expected. After that, the input stream seems closed / full / something else because I get an <code>IOError</code>, specifically a <code>Broken Pipe</code> error when I try to write on <code>stdin</code>.</p>
  
  <p>When I skip the first 9 483 first files, the last ones are tagged without any issue, including the one causing the first error.</p>
  
  <p>My server doesn't produce any error log indicating something fishy happened... Do I handle something incorrectly? Is it normal that the pipe fails after some time?</p>
  
  <pre><code>log = codecs.open('stanford-tagger.log', 'w', 'utf-8')
  p1 = Popen(["java",
              "-cp", JAR,
              "edu.stanford.nlp.tagger.maxent.MaxentTaggerServer",
              "-client",
              "-port", "2020"],
             stdin=PIPE,
             stdout=PIPE,
             stderr=log)
  
  fhi = codecs.open(SUMMARY, 'r', 'utf-8') # a descriptor of the files to tag
  
  for i, line in enumerate(fhi, 1):
      if i % 500:
          print "Tagged " + str(i) + " documents..."
      tokens = ... # a list of words, can be quite long
      try:
          p1.stdin.write(' '.join(tokens).encode('utf-8') + '\n')
      except IOError:
          print 'bouh, I failed ;(('
      result = p1.stdout.readline()
      # Here I do something with result...
  fhi.close()
  </code></pre>