-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Add to shutil the ability to wait until files are definitely deleted #66223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As suggested by Martin in msg170717, shutil should grow some way to block until a given file/directory is actually deleted, due to Windows' scheme of not actually deleting a file until all handles to it are closed. This could take the form of a 'wait=False' parameter to rmtree that causes rmtree to block until the file/dir is gone (which could mean blocking indefinitely), or a new function "wait_until_deleted(name, timeout=None)". |
Patch that adds wait parameter to shutil.rmtree. |
What if other program will create a file with same name in short time after deletion? Then rmtree() will hang in infinity loop. |
With respect to msg224566, is a default timeout a good solution? |
On Linux and some other systems there is an API which allow you to subscribe |
Windows has FindFirstChangeNotification and FileSystemWatcher: |
Is this closer to what Zachary.Ware suggested, patch implements a wait_until_deleted method in C Api using inotify for Linux/FreeBSD. |
This issue is 5 years old and has 2 patches: it's far from being "newcomer friendly", I remove the "Easy" label. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: