Skip to content

Properly close any file in request.FILES at the end of a request. - #2747

Closed
apollo13 wants to merge 1 commit into
django:masterfrom
apollo13:fdleakage
Closed

apollo13 wants to merge 1 commit into
django:masterfrom
apollo13:fdleakage

Conversation

@apollo13

Copy link
Copy Markdown
Member

No description provided.

@mjtamlyn

Copy link
Copy Markdown
Member

Can't see anything terrible. It needs a regression test definitely.

The proposed restriction on handlers seems sane to me.

@apollo13

Copy link
Copy Markdown
Member Author

@mjtamlyn Added tests, aside from docs & release notes it should be good now I hope.

@shaib

shaib commented May 30, 2014

Copy link
Copy Markdown
Member

I'd add one more test, which actually reproduces the complaint -- that is, a view that saves a file from the request.

@apollo13

Copy link
Copy Markdown
Member Author

@shaib: While possible, I prefer to have tests which actually test behavior
instead of running everything through a view and see if everything is okay
-- especially when the problem is well defined like "storage.save is
closing files"

On Fri, May 30, 2014 at 5:29 PM, shaib [email protected] wrote:

I'd add one more test, which actually reproduces the complaint -- that is,
a view that saves a file from the request.

—
Reply to this email directly or view it on GitHub
#2747 (comment).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to a public method on the handler

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer this to 1.8 since it's basically a new feature and should just work (tm) (adding the public method that is)

@apollo13

Copy link
Copy Markdown
Member Author

Updated the release notes, didn't mention file in the upload handlers yet since I don't want to really make it a public API. It's imo a non-issue anyways since files are closed on garbage collection anyways…

Will commit after okays from you.

Comment thread docs/releases/1.7.txt Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially uploaded?

This patch is two-fold; first it ensure that Django does close everything in
request.FILES at the end of the request and secondly the storage system should
no longer close any files during save, it's up to the caller to handle that --
or let Django close the files at the end of the request.
@apollo13

Copy link
Copy Markdown
Member Author

Merged manually into master as e2efc89

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

Successfully merging this pull request may close these issues.

4 participants