[issue46492] BrokenPipeError when piping to head (linux)

2022-01-23 Thread Roy Assis
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

[issue46492] BrokenPipeError when piping to head (linux)

2022-01-23 Thread Roy Assis
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