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

Program received signal SIGPIPE, Broken pipe

The process received a SIGPIPE. The default behaviour for this signal is to end the process. A SIGPIPE is sent to a process if it tried to write to a socket that had been shutdown for writing or isn’t connected (anymore). To avoid that the program ends in this case, you could either make the process ignore SIGPIPE#include <signal.h> … Read more