Description
Summary
We have a problem where emptydirs throws an exception because the device is busy (for .nfsXXXXXX files). This errno is not handled specifically and just raises the Exception.
Is there a good reason why .nfs files cannot be left in the directory? Also there is no test for emptydirs, i would like to write a test and implement a workaround that leaves '.nfs*' files.
Actual behavior
Trying to empty a directory that contains .nfsXXXXXXX files fails.
Traceback (most recent call last):
File "/opt/nipype/nipype/pipeline/plugins/multiproc.py", line 68, in
run_node
result['result'] = node.run(updatehash=updatehash)
File "/opt/nipype/nipype/pipeline/engine/nodes.py", line 458, in run
emptydirs(outdir, noexist_ok=True)
File "/opt/nipype/nipype/utils/filemanip.py", line 788, in emptydirs
raise ex
OSError: [Errno 16] Device or resource busy:
'/some_path/.nfsXXXXXXXXXX'
Expected behavior / Workaround
ignore files that begin with '.nfs' since they will be deleted later anyway
or wait until it is closed.
There already is an except branch:
elcont = os.listdir(path)
if ex.errno == errno.ENOTEMPTY and not elcont:
that is supposed to deal with NFS but elcont is not empty and errno==errno.EBUSY is not handled
so my solution would be to check if the busy resource is a .nfs-file and if it is, ignore the error (pass).
How to replicate the behavior
shared nfs resource: pipeline was stopped on one computer and resumed on another, random .nfsXXX files seem to persist
Platform details:
{'nibabel_version': '2.1.0', 'sys_executable': '/usr/bin/python', 'networkx_version': '1.11', 'numpy_version': '1.9.0', 'sys_platform': 'linux2', 'sys_version': '2.7.9 (default, Jun 29 2016, 13:08:31) \n[GCC 4.9.2]', 'commit_source': 'repository', 'commit_hash': '9eaa2a3', 'pkg_path': '/opt/nipype/nipype', 'nipype_version': '1.0.4-dev+g9eaa2a3', 'traits_version': '4.6.0', 'scipy_version': '0.14.0'}
1.0.4-dev+g9eaa2a3