Roy Assis added the comment:
Resolution in this post:
https://stackoverflow.com/questions/26692284/how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python/26738736
code was changed to:
#sample.py
import sys
from time import sleep
try:
for line in sys.stdin:
print(line
New submission from Roy Assis :
problem:
---
Python raises exception when piping to head. Exception is not caught by try
except.
code:
#sample.py
import sys
from time import sleep
try:
for line in sys.stdin:
print(line, flush=True)
sleep(2)
except:
print(&q