Opened 16 years ago
Closed 16 years ago
#7658 closed (fixed)
Streaming file uploads fail on Windows XP
Reported by: | Owned by: | Michael Axiak | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | 2070-fix | |
Cc: | prigun@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When you attempt to upload a file larger than the memory cutoff it returns a WindowsError when it attempts to delete the temporary file which still has a handle from the python process because it is not being closed.
Attachments (4)
Change History (21)
by , 16 years ago
Attachment: | file_upload_patch.patch added |
---|
comment:1 by , 16 years ago
Summary: | Streaming file uploads fail on Windows XP |
---|
I would also ask the relevant devs to consider adding some exception handling to the file_move_safe function so that even if os.remove(old_file_name) fails the application can continue.
try:
os.remove(old_file_name)
except:
# log the error and continue execution
comment:2 by , 16 years ago
Needs tests: | set |
---|---|
Summary: | → Streaming file uploads fail on Windows XP |
Last comment reset the summary, etc. Sorry.
comment:3 by , 16 years ago
Keywords: | 2070-fix added |
---|---|
Owner: | changed from | to
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 16 years ago
Just updated to the latest revs for both trunk and newforms-admin (7870). Still get the error above in newforms admin but in trunk I now get a IOError "No such file or directory". Here's a snippet of the traceback where it fails:
File "C:\home\Projects\Django\libs\django-trunk\django\core\files\move.py" in file_move_safe
- file_move(old_file_name, new_file_name)
File "C:\Python25\lib\shutil.py" in move
- copy2(src,dst)
File "C:\Python25\lib\shutil.py" in copy2
- copyfile(src, dst)
File "C:\Python25\lib\shutil.py" in copyfile
- fsrc = open(src, 'rb')
comment:6 by , 16 years ago
So it appears there's a reason not to use tempfile.NamedTemporaryFile()
on windows. I'm going to create my own NamedTemporaryFile()
function for windows.
comment:7 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Someone else should probably look at this, but I think this fixes the problems with Windows.
follow-up: 9 comment:8 by , 16 years ago
Still getting the IOError on streaming uploads after applying the new patch.
comment:9 by , 16 years ago
Replying to justin.driscoll@gmail.com:
Still getting the IOError on streaming uploads after applying the new patch.
Yeah. That's bug #7675.
by , 16 years ago
Attachment: | tempfile.2.diff added |
---|
Updated tempfile diff to fix AttributeError problem.
by , 16 years ago
Attachment: | tempfile.3.diff added |
---|
Updated tempfile diff to fix AttributeError problem.
comment:10 by , 16 years ago
Just updated to newforms-admin rev 7888 which from what I can see is inline with trunk and now there appears to be an issue with ImageField and streaming uploads as the PIL check for a valid image fails on streamed file. Should I file this as a new issue?
comment:12 by , 16 years ago
Thanks, I ran a search but didn't find anything. Wanted to ask before I filed a dupe.
comment:13 by , 16 years ago
Cc: | added |
---|
It looks like close method for the TemporaryUploadFile deletes file on Linux and Mac systems
(didn't have a chance to test it on FreeBSD yet), see #7683
comment:14 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:15 by , 16 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
As of Django r8301 I am still getting a WindowsError when streaming uploads are used:
[Error 32] The process cannot access the file because it is being used by another process: 'c:
docume~1
jdrisc~1
locals~1
temp
eu5ium.upload'
comment:17 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Re-resolving as 'fixed', since the newly reported issue is a *new* one and most likely the same as in #8203. I consider it's a new issue since the problem is now not with the streaming upload, namely, but within the storage phase.
Adds a "close" method to TemporaryUploadedFile.