Streaming HTTP response, flushing to the browser

Posted by synic on Stack Overflow See other posts from Stack Overflow or by synic
Published on 2010-05-28T22:25:54Z Indexed on 2010/05/28 22:32 UTC
Read the original article Hit count: 140

Filed under:

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?

© Stack Overflow or respective owner

Related posts about django