Skip to content
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

send2trash function failed to delete a directory with unknown error #70

Open
WentingTan opened this issue Jul 19, 2022 · 2 comments
Open

Comments

@WentingTan
Copy link

WentingTan commented Jul 19, 2022

This function is referred in Jupyter server folder deletion logic. We observed the error in jupyterlab app and here in this description we try to simplify the scenario and reproduce it in a windows command prompt.

In python interpreter, we import the send2trash:
from send2trash import send2trash

And run this code line, deleting the directory:
send2trash('C:\\Users\\traveler\\AppData\\Local\\projects\\Untitled Folder')
In this case the "Untitled Folder" is newly created under a jlabapp project and there is a newly created ipynb file in it, it failed to delete "Untitled Folder" and throws message:

>>> send2trash('C:\Users\traveler\AppData\Local\projects\Untitled Folder')
Traceback (most recent call last):
File "C:\Users\traveler\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\send2trash\plat_win_modern.py", line 61, in send2trash
result = fileop.PerformOperations()
pywintypes.com_error: (-2144927705, 'OLE error 0x80270027', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\traveler\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\send2trash\plat_win_modern.py", line 69, in send2trash
raise OSError(None, error.strerror, path, error.hresult)
OSError: [WinError -2144927705] OLE error 0x80270027: 'C:\Users\traveler\AppData\Local\projects\Untitled Folder'

However, when we close the project tab and reopen it. The above code line (exactly the same func and path) works and was able to delete "Untitled Folder".

Watching "Untitled Folder" in File Explorer and it seems there is no visible difference between the above two cases.

@WentingTan WentingTan changed the title send2trash function failed to delete a directory with unknow error send2trash function failed to delete a directory with unknown error Jul 19, 2022
@arsenetar
Copy link
Owner

Best I can find for that error code is possibly a "sharing violation" so there might have been something else that had been accessing that folder at the time. Is it very reproducible, does it happen every time?

@WentingTan
Copy link
Author

Yes it is reproducible and happens every time. Only happens to .ipynb file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants