473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pipe Error on Windows?

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
import time
import os

(w,r,e) = os.popen3('engine.py')

def receive(r):
print 'staring recv'
while 1:
# get data
try:
data = r.readline()
except Exception, e:
print e
break
if not len(data):
time.sleep(0.1)
continue
else:
print 'controller received:', data
print 'stopping recv'

t = threading.Thread(target=receive, args=(r,))
t.setDaemon(True)
t.start()

for i in range(5):
time.sleep(1)
if not w.closed:
print >>w, 'controller '+str(i)
w.flush()

print 'final:', ''.join(r.readlines())
print 'errors:', ''.join(e.readlines())

r.close()
w.close()
e.close()

#-------------------------
# engine.py
import sys
import threading
import time

outfile = open('enginetest.data', 'w')

def receive():
global outfile
print >>outfile, 'starting recv'
while 1:
# get data
try:
data = sys.stdin.readline()
except Exception, e:
print >>outfile, 'error:', e
break
if not len(data):
time.sleep(0.1)
continue
else:
print >>outfile, data
print >>outfile, data
print >>outfile, 'stopping recv'

t = threading.Thread(target=receive)
t.setDaemon(True)
t.start()

for i in range(4):
time.sleep(1)
if not sys.stdout.closed:
print >>sys.stdout, 'engine',str(i)
sys.stdout.flush()

outfile.close()
Jul 18 '05 #1
0 1213

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
1
by: jenny | last post by:
Hi, I have a java socket program running on AIX 4.3.3.0 platform. It opens a socket and sends data to our customer over a leased fractional T1 line. The line is always connected. However,...
1
by: momena | last post by:
Hi experts, I need to write a perl script that will be called from a series of executables chained thru pipes that read from STDIN and writes to STDOUT. The following code works fine under regular...
2
by: FB's .NET Dev PC | last post by:
I am writing two services in VB.NET, one of which needs to send text strings to the other. After reading, I decided (perhaps incorrectly) that named pipes would be the best interprocess...
0
by: olaf.dietsche | last post by:
Hi, The system is Windows XP and DB2 v8.1.7. I'm trying to load a text file via named pipe into a table. I have two programs: the first program creates the named pipe, waits for a client...
3
by: a | last post by:
Hi everybody, Is it possible to open a named pipe from a php script on Windows? More specifically, I have a Windows service that receives commands through a named pipe, and I'd like to open...
1
by: Tomislav | last post by:
Does anyone know what pipe.log is? I made windows service that works fine on win xp, when I install them on windows 2003 it make log in windows\temp folder with name pipe.log and it grows rapidly...
11
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)
3
by: Jeremy Sanders | last post by:
Hi - I have some code which works under linux. It starts a remote python process using subprocess and communicates to it via a pipe created by os.pipe. As far as I understand, child processes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.