From 518f12983f416c96c399faa3ec5a8f96b9173154 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Sat, 29 Jun 2019 09:19:51 +0200 Subject: [PATCH] build_library: detach after every losetup succeeded To avoid issues with losetup not being cleaned up, we need to call losetup --detach inside the retry loop. --- build_library/disk_util | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build_library/disk_util b/build_library/disk_util index 7fd180b23f..699a173317 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -447,11 +447,10 @@ def PartitionLoop(options, partition): except: attempts += 1 time.sleep(1) + finally: + Sudo(['losetup', '--detach', loop_dev]) - try: - yield loop_dev - finally: - Sudo(['losetup', '--detach', loop_dev]) + yield loop_dev def FormatPartition(options, part): print "Formatting partition %s (%s) as %s" % (