fix intermittent BrokenPipe error on macOS when SHOW_PROGRESS=True

This commit is contained in:
Nick Sweeting 2020-10-31 19:38:54 -04:00
parent 9c6ff5036c
commit 7d4738a674

View file

@ -101,23 +101,14 @@ class TimedProgress:
if self.SHOW_PROGRESS:
# terminate if we havent already terminated
try:
# WARNING: HACKY
# I've spent over 15 hours trying to get rid of this stupid macOS-only
# intermittent (but harmeless) warning when the progress bars end sometimes
# Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
# BrokenPipeError: [Errno 32] Broken pipe
# In the end, this is the only thing I found that makes it
# happen slightly less often:
if platform.system() == 'Darwin':
time.sleep(0.1)
# kill the progress bar subprocess
try:
self.p.close() # must be closed *before* its terminnated
except:
pass
self.p.terminate()
self.p.join()
self.p.close()
if platform.system() == 'Darwin':
time.sleep(0.1)
# clear whole terminal line
try: