X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b27c4cbe64a1266f406572ff04678e048c966584..f79d1cdf7696a3bbcc374df5ce4d1761a28a5ea5:/services/fuse/arvados_fuse/unmount.py?ds=sidebyside diff --git a/services/fuse/arvados_fuse/unmount.py b/services/fuse/arvados_fuse/unmount.py index 1f06d8c91c..144c582ddc 100644 --- a/services/fuse/arvados_fuse/unmount.py +++ b/services/fuse/arvados_fuse/unmount.py @@ -6,6 +6,7 @@ import collections import errno import os import subprocess +import sys import time @@ -153,12 +154,22 @@ def unmount(path, subtype=None, timeout=10, recursive=False): path = os.path.realpath(path) continue elif not mounted: + if was_mounted: + # This appears to avoid a race condition where we + # return control to the caller after running + # "fusermount -u -z" (see below), the caller (e.g., + # arv-mount --replace) immediately tries to attach a + # new fuse mount at the same mount point, the + # lazy-unmount process unmounts that _new_ mount while + # it is being initialized, and the setup code waits + # forever for the new mount to be initialized. + time.sleep(1) return was_mounted if attempted: # Report buffered stderr from previous call to fusermount, # now that we know it didn't succeed. - sys.stderr.write(fusermount_output) + sys.stderr.buffer.write(fusermount_output) delay = 1 if deadline: