异步WSGI与扭曲 [英] Asynchronous WSGI with Twisted

查看:175
本文介绍了异步WSGI与扭曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Web界面扭曲的应用程序,并想用WSGI,而不是直接twisted.web(因为该网站的其余部分是WSGI,我已经有一个实质性的WSGI codeBase的)。

I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase).

我发现了大约WSGIResource扭转的文档页面(http://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html)规定:
像任何其他WSGI容器中,你不能做任何事情异步在你的WSGI应用程序,尽管这是一个扭曲的WSGI容器。

The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html) states: Like any other WSGI container, you can't do anything asynchronous in your WSGI applications, even though this is a Twisted WSGI container.

这是否必须是真的吗?是否有这样做twisted.web风格的异步Web请求处理中WSGI一些低于哈克的方式 - 或许另一个自由软件项目的一部分吗?假如没有的话,我的计划是有WSGI线程通过查询做他们的反应器中的线程和块异步工作,直到数据可用。这不是pretty。

Does this have to be true? Is there some less-than-hacky way of doing twisted.web style asynchronous web request handling in WSGI - perhaps as part of another free software project? Supposing there isn't, my plan is to have WSGI threads do their asynchronous work in the reactor thread and block by polling until the data is available. It's not pretty.

如果有异步处理WSGI请求在扭曲我很想听到一个相当简单的方式。

If there's a reasonably uncomplicated way of asynchronously handling WSGI requests in twisted I'd love to hear it.

推荐答案

为什么要使用WSGI并做异步的东西呢? WSGI的好处是,你可以部署在任何WSGI容器应用程序。如果你开始使用双绞线的API做的事情异步,那么你只能部署Twisted的WSGI容器应用程序。

Why do you want to use WSGI and do asynchronous things? The benefit of WSGI is that you can deploy your application on any WSGI container. If you start using Twisted APIs to do asynchronous things, then you can only deploy your application in Twisted's WSGI container.

您或许应该只使用双绞线网络没有WSGI你的异步code。

You should probably just use Twisted Web without WSGI for your asynchronous code.

这篇关于异步WSGI与扭曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆