build_library: break the attempt loop when losetup succeeds

We need to break the attempt loop when losetup succeeds.
Also we should not use finally, which is called also for success.
This commit is contained in:
Dongsu Park 2019-06-29 10:01:21 +02:00
parent 518f12983f
commit 5bc76098a5

View File

@ -444,11 +444,11 @@ def PartitionLoop(options, partition):
'--sizelimit', str(partition['bytes']),
'--find', '--show', options.disk_image])
loop_dev = loop_dev.strip()
break
except:
Sudo(['losetup', '--detach', loop_dev])
attempts += 1
time.sleep(1)
finally:
Sudo(['losetup', '--detach', loop_dev])
yield loop_dev