IOError: [Errno 32] Broken pipe

Christopher T King squirrel at WPI.EDU
Mon Jun 28 18:47:48 EDT 2004


On 28 Jun 2004, Jay Donnell wrote:

> I'm working on a simple script to manipulate csv files. Right now it
> just prints the first field of the file for each line. Everything
> works fine, but if I use 'head' or 'more' and quit while in more then
> I get
> IOError: [Errno 32] Broken pipe
> 
> Anyone know why this is happening?

That's normal, at least with Unix. When the program on the receiving end
of a pipe decides to close its end for some reason, Unix sends the signal
'SIGPIPE' to the sending end. Python catches this and turns it into an
IOError exception. The only way around this (that I can think of) is to
catch the exception and exit the program gracefully. If you try to send
more data, you will get more IOErrors, since your program has nowhere left
to send data.




More information about the Python-list mailing list