-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support Streaming #30
Comments
Is this on the roadmap?
|
For the record, I ended up bypassing flask-compress for the few requests in which I do streaming. def stream_compress(chunks) :
compressor = zlib.compressobj()
for data in chunks:
out = compressor.compress(data.encode())
if out:
yield out
yield compressor.flush()
@route("/rest/data")
def get_data() :
# Generates an iterator with "yield"
chunks = stream_data()
headers = dict()
if "deflate" in request.headers.get('Accept-Encoding', ''):
headers["Content-Encoding"] = "deflate"
out = stream_compress(chunks)
return Response(
out,
mimetype=mimetype,
headers=headers) |
If anyone comes up with a PR that implements streaming without breaking existing code, I will be happy to review it. |
@alexprengere Working on supporting streaming. |
@alexprengere @raphaeljolivet Instead, I think we should just skip compression if |
Thanks a lot for your investigation, I merged your PR. |
@gilad9366 : Well I disagree. |
@raphaeljolivet Are you sure it's actually streaming to the client and not streaming only to the WSGI middleware and then whole thing compressed at once to the client? |
It is really streaming.
I can see the size growing on the client size.
------- Original Message -------
Le mercredi 13 avril 2022 à 3:02 PM, gilad9366 ***@***.***> a écrit :
… ***@***.***(https://github.com/raphaeljolivet) Are you sure it's actually streaming to the client and not streaming only to the WSGI middleware and then whole thing compressed at once to the client?
I tried running your code and the streaming broke.
—
Reply to this email directly, [view it on GitHub](#30 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAJFLQF3HSRYD73H2MYGPP3VE3AXLANCNFSM5QJWUXUA).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@raphaeljolivet if you want to open a PR, I can take a look at it. |
Here we go ! |
When using Flask Streaming capabilities, flask-compress gathers all the data with get_data() and returns everything at once, breaking the "streaming" paradigm.
You may integrate streaming compression as described in this answer (for deflate here) :
https://stackoverflow.com/a/44387566/254061
The text was updated successfully, but these errors were encountered: