IOError: [Errno 32] Broken pipe when piping: `prog.py | othercmd`
I haven’t reproduced the issue, but perhaps this method would solve it: (writing line by line to stdout rather than using print) You could catch the broken pipe? This writes the file to stdout line by line until the pipe is closed. You also need to make sure that othercommand is reading from the pipe before it gets too big – https://unix.stackexchange.com/questions/11946/how-big-is-the-pipe-buffer