summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-02-14 13:38:43 +0100
committerCarl Hetherington <cth@carlh.net>2022-02-14 13:38:43 +0100
commit114c97a47cbb84d655259b757d5c015e2906f849 (patch)
treec4f0efba9896184e52fa43f075f0321e73858e87
parente73f084d7f776db60ea3904f4b7b6dc73621d1ee (diff)
Try to use finally better to terminate subprocesses when we die.
-rwxr-xr-xcdist15
1 files changed, 8 insertions, 7 deletions
diff --git a/cdist b/cdist
index 21a9ab5..543f1d7 100755
--- a/cdist
+++ b/cdist
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-# Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
+# Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1239,10 +1239,12 @@ def main():
if args.target is None:
raise Error('you must specify -t or --target')
- target = target_factory(args)
- target.build(args.project, args.checkout, get_command_line_options(args))
- if not args.keep:
- target.cleanup()
+ try:
+ target = target_factory(args)
+ target.build(args.project, args.checkout, get_command_line_options(args))
+ finally:
+ if not args.keep:
+ target.cleanup()
elif args.command == 'package':
if args.target is None:
@@ -1262,10 +1264,9 @@ def main():
makedirs(output_dir)
target.package(args.project, args.checkout, output_dir, get_command_line_options(args), not args.no_notarize)
- except Error as e:
+ finally:
if target is not None and not args.keep:
target.cleanup()
- raise
if target is not None and not args.keep:
target.cleanup()