#36293: Extend `django.utils.text.compress_sequence()` to optionally flush data
written to compressed file
-------------------------------+--------------------------------------
Reporter: huoyinghui | Owner: (none)
Type: New feature | Status: closed
Component: HTTP handling | Version: dev
Severity: Normal | Resolution: needsinfo
Keywords: gzip flush | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by Adam Johnson):
I think Natalia got mixed up and meant to report #36655 as a dupe.
In my report there, I demonstrated the issue using HTML, rather than SSE.
It could be similarly troublesome to buffer content when streaming HTML,
especially if there's time between chunks, such as from database queries.
In fact, I think if you're using `StreamingHttpResponse`, any buffering
from outer layers is unacceptable. It can always be done inside your
iterator, if necessary, but once a chunk is ready, Django should pass it
out as fast as possible.
#24242 removed the `flush()` call to reduce the total data transfer. I
don't think this was the right call—latency was not discussed at all. The
OP also seemed to be using a very naive approach, hooking up a streaming
JSON library that yields individual tokens, which sounds like an uncommon
way of using `StreamingHttpResponse`.
So I would say reopen this ticket and revert #24242—no option to flush.
That's the approach I effectively implemented in django-http-compression
([https://github.com/adamchainz/django-http-compression/pull/8 PR]), when
I wasn't aware that `flush()` was ever removed.
--
Ticket URL: <https://code.djangoproject.com/ticket/36293#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070199d075d7ca-a5038ede-2064-473a-a5a3-8d0012844871-000000%40eu-central-1.amazonses.com.