版本:Python3.8.2瓶2.0.1 Werkzeug 2.0.1 Gunicorn 20.1.0
在python3.7或3.8中运行烧瓶,而gunicorn模式是'sync‘或'gevent/eventlet',我在终端中也遇到了同样的错误:"count必须是正整数(got 0)",但是浏览器中的网站似乎没有异常,铬控制台没有报告错误。
Gunicorn配置:
# gunicorn.conf.py
workers = 5
worker_class = "sync" # or "gevent"
bind = "0.0.0.0:8080"输出:
>>> gunicorn application:app -c ./gunicorn.conf.py
Starting gunicorn 20.1.0
Listening at: http://0.0.0.0:8080 (69063)
Using worker: sync # or "gevent"
Booting worker with pid: 69065
Booting worker with pid: 69066
Booting worker with pid: 69067
Booting worker with pid: 69068
Booting worker with pid: 69069
[69065] [ERROR] Error handling request
Traceback (most recent call last):
File "/Users/xxx/.virtualenvs/yyy/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 182, in handle_request
resp.write_file(respiter)
File "/Users/xxx/.virtualenvs/yyy/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 385, in write_file
if not self.sendfile(respiter):
File "/Users/xxx/.virtualenvs/yyy/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 375, in sendfile
self.sock.sendfile(respiter.filelike, count=nbytes)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socket.py", line 482, in sendfile
return self._sendfile_use_sendfile(file, offset, count)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socket.py", line 346, in _sendfile_use_sendfile
self._check_sendfile_params(file, offset, count)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socket.py", line 460, in _check_sendfile_params
raise ValueError(
ValueError: count must be a positive integer (got 0)发布于 2021-10-12 22:40:08
在与已接受的答案相关的注释中,我从模板头部部分中对空JavaScript文件的引用中获得了错误。
<script src="static/js/main.js"></script>一旦我删除了引用,错误就消失了。我只想区分一下,对空文件的引用会导致错误,而不管文件类型如何,而且它不仅仅与url_for函数相关。
发布于 2021-07-05 05:21:02
我在模板中使用了url_for函数来引用一个空的css文件,这导致了异常。
https://stackoverflow.com/questions/68219233
复制相似问题