[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-11 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: > For convenience, a handler that retries unlink() and rmdir() could be > distributed with shutil. For ease of use, it could be enabled by default on > Windows. +1 on that. I bumped into this many times over the years as occasional and

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-09 Thread Eryk Sun
Eryk Sun added the comment: Your case probably isn't due to a anti-malware filesystem filter. Explorer keeps handles open to directories to get updates via ReadDirectoryChangesExW. It opens watched directories with shared delete access, so deleting the child succeeds. But

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-09 Thread Yu Liu
Yu Liu added the comment: These are results on another slower machine. Note these results are attained on Windows 10, while the above on Windows 7. Just in case it has some influence. $ python test.py num_retries: 6 wait_time: 0.0008691726957804373 $

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-09 Thread Yu Liu
Yu Liu added the comment: This time I run it a couple of consecutive times manually. The result shows that the first time it retried 12 times and the wait time was 0.0004259171330071893. Then it seems to be steady, and the num_retried is 3 or 4, and the wait_time is

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-08 Thread Eryk Sun
Eryk Sun added the comment: A sub-millisecond wait is fairly quick, but it depends on the machine speed. I should have included a counter. Try the following. It's not reproducing the problem if num_retries doesn't get incremented. import os import time

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-08 Thread Yu Liu
Yu Liu added the comment: The result is 0.00026412295632975946 on my computer. Does this mean it is caused by an anti-malware program? -- ___ Python tracker

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-07 Thread Eryk Sun
Eryk Sun added the comment: This is not an uncommon problem. If there's one or more existing references to a file or empty directory that were opened with shared delete access, then a delete operation will succeed, but the file or directory will not be unlinked from the

[issue33240] shutil.rmtree fails when the inner floder is opened in Explorer on Windows

2018-04-07 Thread Yu Liu
New submission from Yu Liu : Given the following directory structure on a Windows machine: - foo - bar a call to `shutil.rmtree("foo")` will fail when the inner folder `bar` is opened in an Explorer. The error message indicates the `foo` directory is not empty, while