summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/tty/log.py32
-rw-r--r--lib/spack/spack/main.py13
2 files changed, 20 insertions, 25 deletions
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index 544a9a6c48..51b9caa332 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -809,19 +809,23 @@ class winlog(object):
def background_reader(reader, echo_writer, _kill):
# for each line printed to logfile, read it
# if echo: write line to user
- while True:
- is_killed = _kill.wait(.1)
- self.stderr.flush()
- self.stdout.flush()
- line = reader.readline()
- while line:
- if self.echo:
- self.echo_writer.write('{0}'.format(line.decode()))
- self.echo_writer.flush()
+ try:
+ while True:
+ is_killed = _kill.wait(.1)
+ # Flush buffered build output to file
+ # stdout/err fds refer to log file
+ self.stderr.flush()
+ self.stdout.flush()
+
line = reader.readline()
+ if self.echo and line:
+ echo_writer.write('{0}'.format(line.decode()))
+ echo_writer.flush()
- if is_killed:
- break
+ if is_killed:
+ break
+ finally:
+ reader.close()
self._active = True
with replace_environment(self.env):
@@ -837,7 +841,6 @@ class winlog(object):
self._ioflag = False
else:
self.writer.close()
- self.reader.close()
self.echo_writer.flush()
self.stdout.flush()
self.stderr.flush()
@@ -853,10 +856,7 @@ class winlog(object):
if not self._active:
raise RuntimeError(
"Can't call force_echo() outside log_output region!")
- try:
- yield self
- finally:
- pass
+ yield
def _writer_daemon(stdin_multiprocess_fd, read_multiprocess_fd, write_fd, echo,
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 5f13f0736f..feab2b6f81 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -30,7 +30,7 @@ import llnl.util.lang
import llnl.util.tty as tty
import llnl.util.tty.colify
import llnl.util.tty.color as color
-from llnl.util.tty.log import log_output, winlog
+from llnl.util.tty.log import log_output
import spack
import spack.cmd
@@ -605,14 +605,9 @@ class SpackCommand(object):
out = StringIO()
try:
- if sys.platform == 'win32':
- with winlog(out):
- self.returncode = _invoke_command(
- self.command, self.parser, args, unknown)
- else:
- with log_output(out):
- self.returncode = _invoke_command(
- self.command, self.parser, args, unknown)
+ with log_output(out):
+ self.returncode = _invoke_command(
+ self.command, self.parser, args, unknown)
except SystemExit as e:
self.returncode = e.code