-
Notifications
You must be signed in to change notification settings - Fork 317
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
fix: yield form in fastui_form to keep file handler open #170
base: main
Are you sure you want to change the base?
fix: yield form in fastui_form to keep file handler open #170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much. Please fix tests and and some more tests that would fail without this.
Glad to hear the contribution is appreciated! I'd love to fix the tests and add more, but looking deeper into the issue I am not sure my fix is the correct approach, as it requires changing all lines with I find my mental model of the control flow through the layers of FastUI/FastAPI/Starlette (especially with classes like Starlette's |
Well the tests having odd syntax isn't the end of the world as long as real world cases are handled correctly and elegantly. I think the solution might be as simple as adding |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
+ Coverage 94.30% 94.31% +0.01%
==========================================
Files 11 11
Lines 755 757 +2
==========================================
+ Hits 712 714 +2
Misses 43 43 ☔ View full report in Codecov by Sentry. |
1d0f15d
to
e6ccc96
Compare
Thanks for the guidance! |
@samuelcolvin Any progress on this ? |
I've run into this issue myself. Is this PR going to make it to master or is there another better fix? |
@sydney-runkle / @samuelcolvin, seems like this PR is ready to be merged and would be |
I ran into the same issue as #146, where in all cases the file handler of an UploadFile is already closed when it becomes available in the endpoint function. I found where the closing of a context manager leads to the closing of the filehandler, and found that yielding inside the
request.form()
context instead of returning after it fixes it. I'm not sure if this is the ideal solution (probably not as CI is breaking on the typechecker) but at least it's pretty minimal and fixes the issue, so I thought it useful enough to share.