如何在女服务员身上用 Django 服务龙卷风?

How to serve Tornado with Django on waitress?

我有这个用 django 函数包装的 tornado 应用程序作为 WSGI 应用程序(在 windows 中使用)

from django.core.wsgi import get_wsgi_application
from django.conf import settings
from waitress import serve
settings.configure()

wsgi_app = tornado.wsgi.WSGIContainer(django.core.wsgi.WSGIHandler())
def tornado_app():  
    url = [(r"/models//predict", PHandler),
           (r"/models//explain", EHandler),
           ('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app))]
    return Application(url, db=ELASTIC_URL, debug=options.debug, autoreload=options.debug)

if __name__ == "__main__":
    application = tornado_app()
    http_server = HTTPServer(application)  
    http_server.listen(LISTEN_PORT)
    IOLoop.current().start() 

不确定如何使用服务员, 为了使用女服务员服务,我尝试了 http_server = serve(application),服务器正在启动,现在确定它是正确的,在到达端点时出错

waitress是一个WSGI服务器; Tornado 不基于也不兼容 WSGI。您不能使用 waitress 来为应用程序的 Tornado 部分提供服务。

要在一个线程中为 Tornado 和 WSGI 应用程序提供服务,您需要像在原始示例中那样使用 Tornado 的 HTTPServer。为了更好的可伸缩性,我建议将应用程序的 Tornado 和 Django 部分拆分为单独的进程,并在它们前面放置一个代理,如 nginx 或 haproxy。