我收到“错误处理请求”,我真的无法追溯到特定问题吗?我正在使用gunicorn + nginx,而我的gunicorn设置是
gunicorn run:app -w 4 -b 0.0.0.0:8080 --workers=1 --timeout=300
这是错误消息
2015-10-14 21:27:11,287 DEBG 'myserver' stderr output:
[2015-10-14 21:27:11 +0000] [26725] [ERROR] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 130, in handle
self.handle_request(listener, req, client, addr)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 171, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1478, in full_dispatch_request
response = self.make_response(rv)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1566, in make_response
raise ValueError('View function did not return a response')
ValueError: View function did not return a response
有人可以提示我如何调试吗?我对服务器的使用没有太多经验...谢谢卡尔
tl; dr:这不是gunicorn或nginx的问题。Flask应用程序中的视图功能未返回响应。检查视图函数中的return语句,以获取出现此错误时正在访问的任何路由。
始于线
Traceback (most recent call last):
您可以看到python解释器生成的堆栈跟踪。该堆栈跟踪显示的嵌套函数序列导致到这种地步你的代码失败。以我有限的经验,python解释器堆栈跟踪已可靠地将我定向到我的代码中的错误。
对于您的情况,最后一行:
ValueError: View function did not return a response
提供了有关该错误的更多详细信息,应该使您对发生问题的地方有个很好的了解(您的视图函数未返回响应)。
从底部开始的下一行将向您显示触发错误的函数及其在代码中的确切位置:
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1566, in make_response
raise ValueError('View function did not return a response')
在这种情况下,烧瓶源中的函数会引发错误,因此,除非您对此进行了编辑,否则可能不需要进行修复。基于跟踪末尾的特定ValueError,我将直接进入视图函数。在Flask中,可能看起来像这样(例如Flask教程中的示例):
@app.route('/')
def show_entries():
cur = g.db.execute('select title, text from entries order by id desc')
entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]
return render_template('show_entries.html', entries=entries)
对于您的情况,最后一行似乎是一个不错的起点,因为该错误表明什么也没有返回。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句