Skip to content

Commit

Permalink
fix conda#6538 BrokenPipeError
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Dec 22, 2017
1 parent 6c5d2ba commit 518c285
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions conda/common/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from concurrent.futures import ThreadPoolExecutor
from contextlib import contextmanager
from enum import Enum
from errno import EPIPE, ESHUTDOWN
from functools import wraps
from itertools import cycle
import json
Expand Down Expand Up @@ -326,11 +327,17 @@ def spinner(message=None, enabled=True, json=False):
if json:
pass
else:
if exception_raised:
sys.stdout.write("failed\n")
else:
sys.stdout.write("done\n")
sys.stdout.flush()
try:
if exception_raised:
sys.stdout.write("failed\n")
else:
sys.stdout.write("done\n")
sys.stdout.flush()
except (IOError, OSError) as e:
# Ignore BrokenPipeError and errors related to stdout or stderr being
# closed by a downstream program.
if e.errno not in (EPIPE, ESHUTDOWN):
raise


class ProgressBar(object):
Expand Down Expand Up @@ -368,12 +375,18 @@ def finish(self):
self.update_to(1)

def close(self):
if self.json:
sys.stdout.write('{"fetch":"%s","finished":true,"maxval":1,"progress":1}\n\0'
% self.description)
sys.stdout.flush()
elif self.enabled:
self.pbar.close()
try:
if self.json:
sys.stdout.write('{"fetch":"%s","finished":true,"maxval":1,"progress":1}\n\0'
% self.description)
sys.stdout.flush()
elif self.enabled:
self.pbar.close()
except (IOError, OSError) as e:
# Ignore BrokenPipeError and errors related to stdout or stderr being
# closed by a downstream program.
if e.errno not in (EPIPE, ESHUTDOWN):
raise
self.enabled = False


Expand Down

0 comments on commit 518c285

Please sign in to comment.