summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2017-12-13 12:59:53 +0000
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-12-13 12:52:41 -0500
commitf15874d1fcaed578f5ec6d89b1f97c9b5e03e20e (patch)
tree58389c3e2ea97208a24f114b91e0a6e650503c54
parentc0b1b4675fa6ea9d23762e5ba1a4405afe169c63 (diff)
downloadbuildstream-f15874d1fcaed578f5ec6d89b1f97c9b5e03e20e.tar.gz
utils._tempdir: don't leak on exceptions
-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()