Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django+;uwsgi:如何在HttpResponse中设置无限文件大小_Python_Django_Buffer_Httpresponse_Uwsgi - Fatal编程技术网

Python Django+;uwsgi:如何在HttpResponse中设置无限文件大小

Python Django+;uwsgi:如何在HttpResponse中设置无限文件大小,python,django,buffer,httpresponse,uwsgi,Python,Django,Buffer,Httpresponse,Uwsgi,我正在使用Python2.7、Django==1.7和uwsgi 我需要使用HttpResponse流式传输mp4文件,以便以html格式呈现(例如videotag),如下所示: def test(request): return render(request, 'shared/test.html', {'video_url': BASE_URL + '/stream_video/'}) def stream_v

我正在使用Python2.7、
Django==1.7
uwsgi

我需要使用
HttpResponse
流式传输mp4文件,以便以html格式呈现(例如
video
tag),如下所示:

def test(request):
    return render(request,
                  'shared/test.html',
                  {'video_url': BASE_URL + '/stream_video/'})


def stream_video(request):
    path = '/var/www/test/video_file.mp4'
    video_file = open(path, 'r')
    response = HttpResponse(video_file, content_type='video/mp4')
    response['Content-Length']    = os.path.getsize(path)
    return response
我通过uwsgi使用以下参数运行Django应用程序:

uwsgi --http :8000 --chdir /var/www/test --module test.wsgi --chunked-input-timeout 40000 --post-buffering 12829000 --buffer-size 12829000 --post-buffering-bufsize 12829000 --fastrouter-buffer-size 12829000 --http-buffer-size 12829000
在小视频(小于1MB)中,它工作正常,但在其他情况下,我有uwsgi错误,如下所示:

def test(request):
    return render(request,
                  'shared/test.html',
                  {'video_url': BASE_URL + '/stream_video/'})


def stream_video(request):
    path = '/var/www/test/video_file.mp4'
    video_file = open(path, 'r')
    response = HttpResponse(video_file, content_type='video/mp4')
    response['Content-Length']    = os.path.getsize(path)
    return response
uwsgi_响应_写入_主体_do():对等方重置连接 获取/流式传输视频期间的[core/writer.c行331]/(192.168.0.224) IOError:写入错误

如您所见,我设置了所有缓冲区大小参数来解决这个问题。但这对我不起作用


你的想法是什么?

可能重复@dkol谢谢你的评论,但在这个问题上,视频文件是附件。我需要流式传输。请参阅与StreamHttpResponse相关的另一个问题