首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行具有Gunicorn got的烧瓶“错误处理请求[计数必须是正整数(got 0)]”

运行具有Gunicorn got的烧瓶“错误处理请求[计数必须是正整数(got 0)]”
EN

Stack Overflow用户
提问于 2021-07-02 03:23:48
回答 2查看 2.4K关注 0票数 8

版本: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配置:

代码语言:javascript
复制
# gunicorn.conf.py
workers = 5
worker_class = "sync"  # or "gevent"
bind = "0.0.0.0:8080"

输出:

代码语言:javascript
复制
>>> 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)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-10-12 22:40:08

在与已接受的答案相关的注释中,我从模板头部部分中对空JavaScript文件的引用中获得了错误。

代码语言:javascript
复制
<script src="static/js/main.js"></script>

一旦我删除了引用,错误就消失了。我只想区分一下,对空文件的引用会导致错误,而不管文件类型如何,而且它不仅仅与url_for函数相关。

票数 8
EN

Stack Overflow用户

发布于 2021-07-05 05:21:02

我在模板中使用了url_for函数来引用一个空的css文件,这导致了异常。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68219233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档