Here with uWSGI setup i am getting this error:
File "/home/v3ss/WorkSpace/FastTract/web2py/gluon/fileutils.py", line
376, in copystream
data = src.read(chunk_size)
IOError: error waiting for wsgi.input data
It happens when file size > 300 MB.
I am running using uwsgi.
#!/bin/bash
./uwsgi/uwsgi --http :8000 --chdir ./web2py/ --python-path ./web2py/
--module uwsgihandler \
--socket /tmp/web2py.sock -p 6 \
--close-on-exec # --socket-timeout 6000 --harakiri 6000 --http-timeout
6000 --harakiri-verbose --cpu-affinity 1
here is my controller :
# -*- coding: utf-8 -*-
import os
import urllib
import traceback
def upload():
upfile = request.vars.file
fname = urllib.unquote(request.vars.file.filename)
# cont_length = request.headers.CONTENT_LENGTH
source_path= urllib.unquote(request.vars.source_path)
file_path = os.path.join(source_path,fname)
_chunk_writer(upfile,file_path)
# print "results",type(upfile),upfile.file.read()
return response.json("Done")
def _chunk_reader(FieldOBJ, chunk_size=1024):
while True:
chunk = FieldOBJ.file.read(chunk_size)
# print "CHUNK",chunk
if not chunk:
FieldOBJ.file.close()
break
yield chunk
def _chunk_writer(file_obj,file_path):
CHUNK_SIZE = 1024 * 1024
try:
with open(file_path, 'wb') as fp:
for chunk in _chunk_reader(file_obj,CHUNK_SIZE):
# print chunk
if not chunk:
break
fp.write(chunk)
return True
except:
print "File Error Occoured",traceback.format_exc()
return False
# def _shutil_chunkwriter(file_obj,file_path):
# import shutil
# CHUNK = 1024 * 1024
# out_file=open(file_path, 'wb')
# shutil.copyfileobj(file_obj,fp,CHUNK)
# out_file.close()
# file_obj.close