Question: Is there a way to use flush=True
for the print()
function without getting the BrokenPipeError?
I have a script pipe.py
Ignore SIGPPIE temporarily
I'm not sure how bad an idea this is, but it works:
#!/usr/bin/env python3
import signal
import sys
sigpipe_old = signal.getsignal(signal.SIGPIPE)
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
for i in range(4000):
print(i, flush=True)
signal.signal(signal.SIGPIPE, sigpipe_old)