Re: subprocess -- broken pipe error

2007-07-02 Thread Steve Holden
7stud wrote: > On Jul 2, 2:12 pm, Steve Holden <[EMAIL PROTECTED]> wrote: >> a) Who told you pipes should be unbuffered by default, and b) what difference >> does that make anyway? >> > > a) The docs. > > b) If the pipes were buffered then writing a small amount of data like > "text3" to the pipe

Re: subprocess -- broken pipe error

2007-07-02 Thread Steve Holden
7stud wrote: > On Jul 2, 1:58 pm, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: >> 7stud wrote: >>> Thanks for the response. So are you saying that the only way you >>> can get data out of a pipe is when the subprocess has terminated? >> No, not only because Pipes aren't related to processes in a

Re: subprocess -- broken pipe error

2007-07-02 Thread 7stud
On Jul 2, 2:12 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > a) Who told you pipes should be unbuffered by default, and b) what difference > does that make anyway? > a) The docs. b) If the pipes were buffered then writing a small amount of data like "text3" to the pipe would cause the other side

Re: subprocess -- broken pipe error

2007-07-02 Thread Steve Holden
7stud wrote: > Why doesn't the following program write to the file? > > driver.py > --- > import subprocess as sub > > p = sub.Popen(["python", "-u", "test1.py"], stdin=sub.PIPE, > stdout=sub.PIPE) > > > p.stdin.write("text3") > > while True: > pass > --- > > test1.py: > -

Re: subprocess -- broken pipe error

2007-07-02 Thread 7stud
On Jul 2, 2:03 pm, Bjoern Schliessmann wrote: > 7stud wrote: > > Why doesn't the following program write to the file? > > [...] > > It just hangs, and then when I hit Ctrl+C and look in the file, > > the data isn't in there. > > Also, the pipe may be unbuffered by > default; file access isn't. >

Re: subprocess -- broken pipe error

2007-07-02 Thread 7stud
On Jul 2, 1:58 pm, Bjoern Schliessmann wrote: > 7stud wrote: > > Thanks for the response. So are you saying that the only way you > > can get data out of a pipe is when the subprocess has terminated? > > No, not only because Pipes aren't related to processes in any > special way. > > He said that

Re: subprocess -- broken pipe error

2007-07-02 Thread Bjoern Schliessmann
7stud wrote: > Why doesn't the following program write to the file? > [...] > It just hangs, and then when I hit Ctrl+C and look in the file, > the data isn't in there. I suppose your running child process isn't closed cleanly if you terminate the parent process. Also, the pipe may be unbuffered

Re: subprocess -- broken pipe error

2007-07-02 Thread Bjoern Schliessmann
7stud wrote: > Thanks for the response. So are you saying that the only way you > can get data out of a pipe is when the subprocess has terminated? No, not only because Pipes aren't related to processes in any special way. He said that you can't write to a pipe whose reader has already terminat

Re: subprocess -- broken pipe error

2007-07-02 Thread 7stud
Why doesn't the following program write to the file? driver.py --- import subprocess as sub p = sub.Popen(["python", "-u", "test1.py"], stdin=sub.PIPE, stdout=sub.PIPE) p.stdin.write("text3") while True: pass --- test1.py: - import sys data = sys.stdin.read() f = open("a

Re: subprocess -- broken pipe error

2007-07-02 Thread 7stud
On Jul 2, 11:32 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jul 2, 1:12 pm, 7stud <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > Can someone explain what a broken pipe is? The following produces a > > broken pipe error: > > > -- > > import subprocess as sub > > > p = sub.Popen(

Re: subprocess -- broken pipe error

2007-07-02 Thread [EMAIL PROTECTED]
On Jul 2, 1:12 pm, 7stud <[EMAIL PROTECTED]> wrote: > Hi, > > Can someone explain what a broken pipe is? The following produces a > broken pipe error: > > -- > import subprocess as sub > > p = sub.Popen(["ls", "-al", "../"], stdin=sub.PIPE, stdout=sub.PIPE) > > print p.stdout.read() > #out

subprocess -- broken pipe error

2007-07-02 Thread 7stud
Hi, Can someone explain what a broken pipe is? The following produces a broken pipe error: -- import subprocess as sub p = sub.Popen(["ls", "-al", "../"], stdin=sub.PIPE, stdout=sub.PIPE) print p.stdout.read() #outputs the files correctly p.stdin.write("ls\n") #IOError: [Errno 32] Bro