使异步接口对 mod_python 用户看起来是同步的

发布于 2024-08-30 12:36:53 字数 571 浏览 5 评论 0原文

我有一个 Python 驱动的 Web 界面,由 Apache 2.2、mod_python 和 Python 2.4 提供支持。我需要使异步进程对该 Web 界面的用户显得同步。

当用户访问此网站上的一个模块时:

  1. 将使用唯一标识符联系外部 SOAP 接口,并使用数字 N 进行响应
  2. 外部接口将通过在 1 之间联系我的计算机上的 SOAP 服务器来异步响应和 10 次(数字 N 告诉我们将收到多少个响应)

我需要以某种方式聚合这些响应并将它们传递到原始模块,该模块将向用户显示信息。目标是使该过程对用户来说看起来是同步的。

处理此同步问题的最佳方法是什么?这是 Twisted 非常适合的东西吗?

我并不局限于使用 Python 作为解决方案,尽管它是首选,因为服务器上的其他所有内容都是用 Python 编写的。我更喜欢既可扩展又需要最少编程时间的解决方案(尽管我知道这些属性有些不一致)。

I have a Python-driven web interface powered by Apache 2.2 with mod_python and Python 2.4. I need to make an asynchronous process appear synchronous to users of this web interface.

When users access one module on this website:

  1. An external SOAP interface will be contacted with a unique identifier and will respond with a number N
  2. The external interface will respond asynchronously by contacting a SOAP server on my machine between 1 and 10 times (the number N tells us how many responses we will receive)

I need to somehow aggregate these responses and pass them to the original module which will display the information back to the user. The goal is to make the process appear synchronous to the user.

What is the best way to handle this synchronization issue? Is this something Twisted would be well-suited for?

I am not restricting myself to Python for the solution, though it is preferred because everything else on the server is in Python. I prefer a solution that is both scalable and will take a minimal amount of programming time (though I understand that these attributes are somewhat at odds).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阪姬 2024-09-06 12:36:53

也许您可以使用 Orbited 来通过与 Web 客户端的长期 HTTP 连接来获取 Ajax 推送。 Orbited 是基于 Twisted 的,所以我认为如果您已经了解 Twisted,那么看看它是有意义的。请查看此教程开始使用。

Maybe you can use Orbited to get ajax push with long-lived HTTP connections to your web clients. Orbited is based on Twisted, so I think it makes sense to look at if you already know Twisted. Have a look at this tutorial to get started.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文