Commit af82f867 authored by rgaudin's avatar rgaudin
Browse files

Added delayed attempts at renaming image file after QEMU's second phase

Windows might fail to rename the image because “file is in used by another process”.
parent 7e41ac3b
......@@ -322,7 +322,7 @@ class _RunningInstance:
try:
self._qemu.wait(timeout)
except subprocess.TimeoutExpired:
pass
self._qemu.terminate()
with self._cancel_event.lock() as cancel_register:
cancel_register.unregister(self._qemu.pid)
self._qemu = None
......
......@@ -360,7 +360,7 @@ def run_installation(
# wait for QEMU to release file (windows mostly)
logger.succ("Image creation successful.")
time.sleep(10)
time.sleep(20)
except Exception as e:
logger.failed(str(e))
......@@ -378,7 +378,20 @@ def run_installation(
else:
try:
# Set final image filename
os.rename(image_building_path, image_final_path)
tries = 0
while True:
try:
os.rename(image_building_path, image_final_path)
except Exception as exp:
logger.err(exp)
tries += 1
if tries > 3:
raise exp
time.sleep(5 * tries)
continue
else:
logger.std("Renamed image file to {}".format(image_final_path))
break
# Write image to SD Card
if sd_card:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment