【发布时间】:2015-03-25 19:42:36
【问题描述】:
问题可以分为两个独立的部分。
-
我有以下项目结构
|- project | |-- app/ - directory with actual project code | |-- app.py - imports something from app/ and call create_app当我运行
gunicorn时,我应该将他指向app对象,该对象实际上是在app.py中创建的。所以我收到一个错误,因为 gunicorn 将app:app视为一个包。唯一的方法是重命名? -
我使用工厂方法来创建应用程序。所以我在 app.py 中导入
create_app函数并将其从flask.ext.script传递给Manager。我将经理对象传递给 gunicorn。在这种情况下, gunicorn 运行正常,但是一旦第一个请求到来,我就会收到以下错误:[2015-03-25 15:38:11 +0000] [14395] [ERROR] Error handling request Traceback (most recent call last): File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 52, in handle self.handle_request(listener_name, req, client, addr) File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 159, in handle_request super(GeventWorker, self).handle_request(*args) File "/opt/env/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 105, in handle_request respiter = self.wsgi(environ, resp.start_response) TypeError: __call__() takes at most 2 arguments (3 given)也许我可以创建一些文件
wsgi.py并为 gunicorn 提供当前应用程序?
【问题讨论】: