On Nov 28, 11:07 pm, Preston Holmes <pres...@ptone.com> wrote:
> My expectation was that it was possible to 'stream' a response back to
> a browser from a view, where that response is 'trickled' onto the
> browser page.  I had done this a while back in cherrypy and it worked
> as expected.
>
> a super simple view demonstrates the issue.  Instead of a series of
> numbers marching onto the page, there is a delay and then the whole
> response is written to the page.  I had disabled commonmiddleware to
> avoid any chance that I was hitting #7581
>
> Is this some limitation of runserver?
>
> from django.http import HttpResponse
> import time
>
> def streamer():
>     for x in range(50):
>         yield str(x)
>         time.sleep(.2)
>
> def writeback (request):
>     return HttpResponse(streamer(), mimetype="text/plain")
>
> insight welcome
>
> -Preston

Answering my own question in case anyone else runs into this.  It is
an issue with Safari buffering the first 1K

So all you need to do to fix it is add a line like:

yield ''.ljust(1024,'\0')

in the generator before your loop.

-Preston

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to