加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 无法使用gunicorn运行龙卷风应用程序

发布时间:2020-12-20 13:51:13 所属栏目:Python 来源:网络整理
导读:我无法使用gunicorn运行龙卷风应用程序.启动应用程序时出错.我想用gunicorn运行它,因为我需要一些很好的功能,如:graceful-timeout,response-timeout等… 龙卷风app: $cat wsgi.py 源代码: import tornado.webimport tornado.wsgifrom api.handler import
我无法使用gunicorn运行龙卷风应用程序.启动应用程序时出错.我想用gunicorn运行它,因为我需要一些很好的功能,如:graceful-timeout,response-timeout等…

龙卷风app:

$cat wsgi.py

源代码:

import tornado.web
import tornado.wsgi
from api.handler import MainHandler,ApiV2Handler,InvalidRequestHandler


def app(*args):
    app = tornado.web.Application([
        (r"/",MainHandler),(r"(/v3/(w+)/(w+)/)",ApiV2Handler),(r"(/v3/(w+)/(w+))",InvalidRequestHandler)
    ])
    return tornado.wsgi.WSGIContainer(tornado.wsgi.WSGIAdapter(app))

庆典:

$gunicorn wsgi:app --bind 127.0.0.1:9080

追溯:

[2015-07-06 14:41:16 +0000] [21806] [INFO] Starting gunicorn 19.3.0
[2015-07-06 14:41:16 +0000] [21806] [INFO] Listening at: http://127.0.0.1:9080 (21806)
[2015-07-06 14:41:16 +0000] [21806] [INFO] Using worker: sync
[2015-07-06 14:41:16 +0000] [21811] [INFO] Booting worker with pid: 21811
[2015-07-06 14:41:21 +0000] [21811] [ERROR] Error handling request
Traceback (most recent call last):
  File "venv/lib/python2.7/site-packages/gunicorn/workers/sync.py",line 130,in handle
    self.handle_request(listener,req,client,addr)
  File "venv/lib/python2.7/site-packages/gunicorn/workers/sync.py",line 176,in handle_request
    for item in respiter:
TypeError: 'WSGIContainer' object is not iterable
^C[2015-07-06 14:41:23 +0000] [21806] [INFO] Handling signal: int
[2015-07-06 14:41:23 +0000] [21811] [INFO] Worker exiting (pid: 21811)
[2015-07-06 14:41:23 +0000] [21806] [INFO] Shutting down: Master

有任何想法吗?

Ben Darnell的更新:

我试过这个:

import tornado.web
import tornado.wsgi
from api.handler import MainHandler,InvalidRequestHandler)
    ])
    return tornado.wsgi.WSGIAdapter(app)

但结果是一样的:

TypeError: 'WSGIAdapter' object is not iterable

解决方法

适合我:

gunicorn -k tornado wsgi:app

wsgi.py

import tornado.web
import tornado.wsgi
from api.handler import MainHandler,InvalidRequestHandler

app = tornado.web.Application([
    (r"/",InvalidRequestHandler)
])

祝好运!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读