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
wsgi: improve error message when returning without start_response #444
base: master
Are you sure you want to change the base?
Conversation
Just took a look at the CI results, and this definitely breaks some things. Given the number of failed tests, I looked over PEP-333 to check my assumption about start_response being required and found this:
...which is exactly what my PR does. I'd still like for this to be changed, but it's late and I don't have any clever ideas for how to go about it. Moving this to an issue. |
Thank you, I'll take it from here. |
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
=======================================
+ Coverage 45% 51% +6%
=======================================
Files 89 84 -5
Lines 11223 9674 -1549
Branches 1982 1687 -295
=======================================
- Hits 5132 5017 -115
+ Misses 5748 4319 -1429
+ Partials 343 338 -5
Continue to review full report at Codecov.
|
Would it make sense to move the Content-Length check and warning about start_response() after the first read of the returned data, but before any data is sent? That should satisfy the spec, although simply moving it into the for loop seems clunky. |
Ah, now I think AssertionError is what has broken tests. It's an exception raised with Also, you're breaking all generator applications, because their call returns instantly and they execute only while iterating Moving content-length check is orthogonal to this matter. It would be better for sure. But please make it a separate patch/commit. |
Today I discovered that if you return from your WSGI function without calling start_response() first, you get a rather unhelpful traceback:
That you have to call start_response() before returning is WSGI 101, but I probably should have been asleep a few hours ago, so it took me a while to work backwards from this traceback to the error in my code. This patch should be a relatively simple change that makes it clear what the issue is.