diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py index bef20025bafc7a..4a4aec23854400 100644 --- a/lib/spack/llnl/util/lock.py +++ b/lib/spack/llnl/util/lock.py @@ -213,13 +213,15 @@ def __enter__(self): return self._as def __exit__(self, type, value, traceback): + suppress = False if self._exit(): if self._as and hasattr(self._as, '__exit__'): - self._as.__exit__(type, value, traceback) + if self._as.__exit__(type, value, traceback): + suppress = True if self._release_fn: - self._release_fn(type, value, traceback) - if value: - raise value + if self._release_fn(type, value, traceback): + suppress = True + return suppress class ReadTransaction(LockTransaction):