Broken pipe with os.popen3()

Christoph Krammer redtiger84 at googlemail.com
Tue Apr 10 09:39:19 EDT 2007


Hello everybody,

I try to use an external OCR tool to convert some binary image data to
text. The image is in one variable, the text should be converted to
another. I use the following code:

  (si, so, se) = os.popen3('ocrad')
  si.write(frame)
  si.close()
  messagetext += so.read()

This code leads to a broken pipe error. I think this is because of the
command already writing data to stdout after getting the first part of
the input. But when I change the order of the code lines, i.e. opening
the reading pipe so before writing to si, the program hangs, because
no data is written to stdout before the first bytes are written to
stdin. Any idea how to solve this issue? How do I read and write
simultaneously?

Thanks in advance,
 Christoph




More information about the Python-list mailing list