-
Notifications
You must be signed in to change notification settings - Fork 272
File not closing after Upload() #129
Comments
Can you post the code you use to upload? |
Sure thing, this is in a for loop that uploads a .png file, then deletes it. It fails on the first run through. upfile = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": out_folder}]}) It gets that WinError32 on os.remove() |
Can confirm. Here's my code:
And here's the traceback (with shortened path) Any update on this? EDIT: |
I found a work around where you can basically just free the variable using something like del fileHandle and then use the os.remove(compressed_file_path) to delete the file. |
I found a solid workaround that uses PyDrive's public API: I think the ideal fix is to make SetContentFile not open the file as it does here: https://github.com/gsuitedevs/PyDrive/blob/68cea204cdcd10bab9321580164c8f4961385a0f/pydrive/files.py#L175 |
@robrothschild You need to manually close the file handle upfile = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": out_folder}]}) |
I'm trying to delete a .zip file from my local system after uploading it to drive. The issue is that one the file is uploaded I get the following error:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'test.zip'
To delete the file I use os.remove but even when I try to remove it from the file manager it wont let me.
The text was updated successfully, but these errors were encountered: