Title: shutil.rmtree using vagrant synched folder fails
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: PeterFS
Priority: normal Keywords:

Created on 2020-01-14 09:45 by PeterFS, last changed 2020-01-15 07:13 by PeterFS.

File name Uploaded Description Edit
Vagrantfile PeterFS, 2020-01-14 09:45
Messages (2)
msg359961 - (view) Author: Peter Liedholm (PeterFS) * Date: 2020-01-14 09:45
Python 3.6.9
Ubuntu 18.04
python3 -c 'import shutil; shutil.rmtree("1a")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/", line 486, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.6/", line 424, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib/python3.6/", line 424, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib/python3.6/", line 428, in _rmtree_safe_fd
    onerror(os.rmdir, fullname, sys.exc_info())
  File "/usr/lib/python3.6/", line 426, in _rmtree_safe_fd
    os.rmdir(name, dir_fd=topfd)
OSError: [Errno 26] Text file busy: '4a'
Reproduction method
mkdir synched_folder\1a\2a\3a\4a
mkdir synched_folder\1a\2b\3a\4a
mkdir synched_folder\1b\2a\3a\4a
choco install vagrant
Save Vagrantfile in empty folder
vagrant box add ubuntu/bionic64
vagrant up
vagrant ssh
cd synched_folder
python3 -c 'import shutil; shutil.rmtree("1a")'
*** Error message ***
rm -r 1a
*** Works fine ***
msg360028 - (view) Author: Peter Liedholm (PeterFS) * Date: 2020-01-15 07:13
Problem is also reported in virtualbox

From that ticket some more analysis is done;
strace reveals that Python has kept an open fd for the directory being removed.
Date User Action Args
2020-01-15 07:13:06PeterFSsetmessages: + msg360028
2020-01-14 09:45:52PeterFScreate