summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py
index b04ce408c..30c79ab67 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -726,10 +726,11 @@ def _tempdir(suffix="", prefix="tmp", dir=None):
if os.path.isdir(tempdir):
shutil.rmtree(tempdir)
- with _signals.terminator(cleanup_tempdir):
- yield tempdir
-
- cleanup_tempdir()
+ try:
+ with _signals.terminator(cleanup_tempdir):
+ yield tempdir
+ finally:
+ cleanup_tempdir()
# _kill_process_tree()