473,978 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('ocra d')
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 2425
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('ocra d')
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12184
by: Frank de Bot | last post by:
Hi, occasionaly I find in my apache logs that fastcgi had a broken pipe error with php running as fastcgi. the logs are like this: -- > (32)Broken pipe: > FastCGI: comm with server /opt/guide/ppi.searchy.net/cgi-bin/php.fcgi" > aborted: write failed > FastCGI: incomplete
1
2838
by: user | last post by:
How can I get the exit status from a "popen2" pipe? For example, from child_stdout, child_stdin, child_stderr = popen2.popen3(command) how can I tell what the exit status it? Want to find out if a command actuall succeeded.
1
2311
by: Chris S. | last post by:
A wrote a small class to handle IO through pipes, but the connection only seems to work in one direction. The following code defines connection.py, engine.py, and controller.py. Once connected, the engine is only able to send and the controller recieve. Also, this only works when using popen2.popen3. Using os.popen3 doesn't work at all and seems to behave completely differently. What could be causing these problems? Any help is greatly...
0
1244
by: Chris S. | last post by:
When I use os.popen3 to communicate through pipes under Windows, the data is only one-way, namely from child to parent. Below are example scripts. Is this a bug in the Windows implementation or am I missing something? Any help is appreciated. #---------------------------------- # controller.py import threading import sys
1
8201
by: Ruben | last post by:
I am reading a large text file a chunk at a time using the readlines(buffer_size) statement. I get an IOERROR ERRNO 32 Broken Pipe command when I "pipe" the output to MYSQL database using the following command: python script.py | mysql I am using RED HAT 9 Linux. The problem only happens if I use the pipe to MYSQL. It breaks but it gets to process around 1000 MYSQL statements.
2
8640
by: Nigel King | last post by:
I have a problem with the logging module. It reports a Broken Pipe error after outputing to the log file occasionally (5%). This does not appear to happen on Mac OSX using current finked python (2.3.3) but does appear to occur on Python 2.3.4 running on a very old Redhat Linux xxxxx 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686. The actual logged error follows my signature. Note that "files used:-" has been sent to the file. From a...
4
6123
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
4
2466
by: Bart | last post by:
Hi everyone! Im using module that gives errors to stderr/stdout (generated by SWIG) Problem is that I need to parse this errors/information from module. os.popen3 looks nice but this executes command not function. Is there any solution? Best regards
11
21630
by: 7stud | last post by:
Hi, Can someone explain what a broken pipe is? The following produces a broken pipe error: ---------- import subprocess as sub p = sub.Popen(, stdin=sub.PIPE, stdout=sub.PIPE)
0
10176
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10922
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10088
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8466
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6426
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5163
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.