470,647 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Broken pipe with os.popen3()

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

Apr 10 '07 #1
1 2226
Christoph Krammer wrote:
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()
If you use popen you should use *one* filehandle. The app
hangs because the buffer is full. See
http://docs.python.org/lib/popen2-flow-control.html
--
Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: ni**************@thomas-guettler.de

Apr 10 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Frank de Bot | last post: by
1 post views Thread by user | last post: by
1 post views Thread by Chris S. | last post: by
reply views Thread by Chris S. | last post: by
1 post views Thread by Ruben | last post: by
2 posts views Thread by Nigel King | last post: by
4 posts views Thread by Bart | last post: by
11 posts views Thread by 7stud | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.