-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
streaming a response with iter_lines doesn't work #989
Comments
Change your line: for line in req.iter_lines(): to: for line in req.iter_lines(chunk_size=10): You'll find this works. =) @sigmavirus24: IIRC, you worked on the streaming stuff last. Why is the default iter_lines chunk size so large (10240 bytes)? Is there a design decision I don't know about there? |
confirmed, chunk_size=10 does fix the issue. I'll leave this issue open, until it's decided what the default should be. |
@Lukasa I think you have me mistaken for someone but if I remember correctly |
Also @gdamjan it was already decided if I remember correctly so you can close this if you feel your needs were met. At this point, with the refactor coming up we could change it to half the current size since we can really announce the breaking changes then. But that still wouldn't fix his problem. To try to phrase this how @kennethreitz will see it, 90% of people's cases will be sufficiently met by this default, and probably 10% will be affected negatively. He likes to ignore that 10% if possible. (Paraphrasing from one of his talks.) |
Is this related to any of the issues discussed in #844? |
@slingamn yes, the first item on your list I believe is related |
No, item 4 is the relevant one. =) |
10 kB is simply ludicrously large. If you load my website homepage, you'll get only slightly more than 10kB of data in total. That includes CSS, images, Javascript, the lot. To use that as the default line size is braindead. |
I agree, this seems foolishly large. |
iter_content's existance, however, based on the concept of extremely large files. |
So leave |
+1 |
Got a preference for what default value to use? =) |
Erp, my mistake, thought this was all iter_content related. |
From #844 seems like people liked 1024 |
It's certainly likely to be better than what we've got. It wouldn't have prevented this issue being raised, though. |
1024 is still too much for ex. when streaming CouchDB's changes feed in continuous mode. |
We can also do 512, 256, 128, 64, 32, 16, or 8. Only the last of which would have prevented this issue. Pick your poison. :P |
@sigmavirus24: Good point well made. =D Nevertheless, I'd be inclined to go slightly smaller. 512 is tempting. |
What are the usage scenarios of iter_lines ? |
Oh, OK, I get the context now. One thing I've been meaning to get around to: understanding It looks like it reads a byte at a time in some cases and |
You mean buffer the stream so we can return the default sizes? I was thinking of this but I realized it isn't realistic for every situation. |
Resolved (finally!) by #1122. |
Using the following simple server to simulate a streaming http service, requests 0.14.2 doesn't stream the response. it waits until some amount of data is received or until the end.
The client
The server
The text was updated successfully, but these errors were encountered: