From 48440766dfd7ea381367f8d957372d262719c8e8 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 14 Aug 2017 05:10:40 -0700 Subject: Fix exit call in `SpackError.die()` - Previously we would use `os._exit()` in to avoid Spack error handling in the parent process when build processes failed. This isn't necessary anymore since build processes propagate their exceptions to the parent process. - Use `sys.exit` instead of `os._exit`. This has the advantage of automatically flushing output streams on quit, so output from child processes is not lost when Spack exits. --- lib/spack/spack/error.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py index 7b86415202..6e48a4e76c 100644 --- a/lib/spack/spack/error.py +++ b/lib/spack/spack/error.py @@ -24,7 +24,6 @@ ############################################################################## from __future__ import print_function -import os import sys import llnl.util.tty as tty @@ -54,7 +53,8 @@ class SpackError(Exception): # basic debug message tty.error(self.message) if self.long_message: - print(self.long_message) + sys.stderr.write(self.long_message) + sys.stderr.write('\n') # stack trace, etc. in debug mode. if spack.debug: @@ -66,7 +66,7 @@ class SpackError(Exception): # run parent exception hook. sys.excepthook(*sys.exc_info()) - os._exit(1) + sys.exit(1) def __str__(self): msg = self.message -- cgit v1.2.3-60-g2f50