popen2: Broken pipe for large files

Milos Prudek milos.prudek at tiscali.cz
Mon Jun 10 21:18:56 CEST 2002


In Python 2.1, is there a size limit when creating pipes with popen2() ?

The following function fails because of a broken pipe if the size of T 
is larger than 21000:

T=File.read()
cmd='file -b -'
w,r=os.popen2(cmd,'b',1000000)
w.write(T)
w.close()
X = r.read().split()
print X

The error message:
Traceback (most recent call last):
   File "./p26.py", line 33, in ?
     w.close()
IOError: [Errno 32] Broken pipe

I tried to specify buffer size 1000000, but it did not help.

The only possible solution so far is to change the first line:

T=File.read()[:20000]

-- 
Milos Prudek







More information about the Python-list mailing list