@@ -305,23 +305,29 @@ so will error out if something goes awry. Note that this function only does
305
305
something when using a squashfs shard on Linux. All other combinations of
306
306
shard archive type and platform result in a no-op.
307
307
"""
308
- function unmount (cs:: CompilerShard , build_prefix:: String ; verbose:: Bool = false , fail_on_error:: Bool = false )
308
+ function unmount (cs:: CompilerShard , build_prefix:: String ; verbose:: Bool = false , fail_on_error:: Bool = false , tries :: Int = 3 )
309
309
# Only try to unmount if it's mounted
310
310
if Sys. islinux () && is_mounted (cs, build_prefix)
311
311
mpath = mount_path (cs, build_prefix)
312
312
if verbose
313
313
@debug (" Unmounting $(mpath) `" )
314
314
end
315
- try
316
- cmd = ` $(sudo_cmd ()) umount $(mpath) `
317
- run (cmd, verbose ? (devnull , stdout , stderr ) : (devnull , devnull , devnull ))
318
-
319
- # Remove mountpoint directory
320
- rm (mpath; force= true , recursive= false )
321
- catch e
322
- # By default we don't error out if this unmounting fails
323
- if e isa InterruptException || fail_on_error
324
- rethrow (e)
315
+ # Try to unmount a few times
316
+ for ntry in 1 : tries
317
+ try
318
+ cmd = ` $(sudo_cmd ()) umount $(mpath) `
319
+ run (cmd, verbose ? (devnull , stdout , stderr ) : (devnull , devnull , devnull ))
320
+
321
+ # Remove mountpoint directory
322
+ rm (mpath; force= true , recursive= false )
323
+ break
324
+ catch e
325
+ # By default we don't error out if this unmounting fails
326
+ if e isa InterruptException || fail_on_error
327
+ rethrow (e)
328
+ end
329
+ @info (" Couldn't unmount $(mpath) , trying again..." )
330
+ sleep (0.1 )
325
331
end
326
332
end
327
333
end
0 commit comments