I've got a view like the following:
from django.views.decorators.http import condition
def stream():
for i in range(0, 40):
yield " " * 1024
yield "%d" % i
time.sleep(1)
@condition(etag_func=None):
def view(request):
return HttpResponse(stream(), mimetype='text/html')
However, it definitely doesn't seem to be streaming at all. All the data is dumped at once, at the end, after about 40 seconds. How can I get it to flush correctly?
To make http streaming work, your middleware, WSGI container, and web server (as well as the reverse-proxy/load-balancer if you use an nginx+apache2 syle deployment) all have to support it. Disable the middleware and remove some of the layers until it works (anything that does caching or sets etags is out), then add them back. I don't know what stack you have, but IIRC apache2 + mod_python is OK with streaming, though it's not the recommended way to serve Django.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With