Use the pure python io module to avoid some interaction between gunicorn, wsgi, and bufferedreader that prevents gunicorn from properly sending the files.

This commit is contained in:
Jake Moshenko 2014-09-09 22:28:25 -04:00
parent c9e1648781
commit 548f855f71
2 changed files with 3 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import magic
from uuid import uuid4
from flask import url_for, request, send_file, make_response, abort
from flask.views import View
from io import BufferedReader
from _pyio import BufferedReader
logger = logging.getLogger(__name__)

View file

@ -7,7 +7,7 @@ import boto.gs.connection
import boto.s3.key
import boto.gs.key
from io import UnsupportedOperation, BufferedIOBase
from io import BufferedIOBase
from storage.basestorage import BaseStorage
@ -18,15 +18,12 @@ logger = logging.getLogger(__name__)
class StreamReadKeyAsFile(BufferedIOBase):
def __init__(self, key):
self._key = key
self._finished = False
def read(self, amt=None):
if self._finished:
if self.closed:
return None
resp = self._key.read(amt)
if not resp:
self._finished = True
return resp
def readable(self):