On Sun, May 16, 2010 at 10:25 PM, Graham Dumpleton
<[email protected]> wrote:
> I asked you:
>
> """
> Are you using wsgi.file_wrapper to optimise serving the file, or using
> your own mechanism for streaming.
> """
>
> Can you at least answer that question so I might now where to start looking?
>
> An actual piece of code showing how you are streaming file back would be 
> ideal.
>
> I know that when streaming yourself, that there are issues if you were
> silly enough to return a single 2GB or greater string, presuming you
> have enough memory, but if you use wsgi.file_wrapper, don't know of
> any issues.
>
> Graham

Below is the code from the Django view that I used with mod_python and
then with mod_wsgi, no such silliness:

--
    class DownloadIterWrapper:
        def __init__(self, stream, chunk_size=1024 ** 2):
            self.stream = stream
            self.chunk_size = chunk_size
        def next(self):
            data = self.stream.read(self.chunk_size)
            if not data:
                raise StopIteration
            return data
        def __iter__(self):
            return self

...

    response = HttpResponse(DownloadIterWrapper(download),
mimetype=file_info.get_mime(download))
    download.seek(0)
    return response
--

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to