Python 3 的事件循环实现?

发布于 2024-11-26 06:01:47 字数 275 浏览 1 评论 0原文

有谁知道可用于 Python 3 的事件循环库(或绑定)?如果它只支持 UNIX 系统也没关系,但我更喜欢也支持 Windows 系统。

预计到达:我意识到编写一个事件循环系统并不是非常困难。但是,我不想重新发明轮子(这些天我们仍然鼓励不要这样做,对吧?;-))

这是为服务器应用程序计划的,所以显然我想要一些不与GUI小部件工具包什么的。

如果答案是“不,没有”(可能;我确实找不到)那么我很可能会为 libev 创建一个 Python 3 的绑定。

Does anyone know of an event loop library (or bindings) available for Python 3? It's okay if it only does UNIX systems, though I would prefer something that does Windows as well.

ETA: I realize that it is not terribly difficult to write an event loop system. However, I don't want to reinvent the wheel (we are still encouraging not doing so these days, right? ;-))

This is planned for a server application, so obviously I'd want something that isn't tied to a GUI widget toolkit or something.

If the answer is "Nope, there isn't one" (probably; I sure as heck can't find one) then I will most likely create a binding for Python 3 for libev.

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

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

发布评论

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

评论(2

离去的眼神 2024-12-03 06:01:47

我建议这样:

while True:
    while queue:
        queue.pop()()

但是,为了使其工作,您需要让事件系统将可调用事件放入队列中。

(如果您对特定框架(例如 GTK、Qt、WxWidgets、NCurses、Cocoa、Winforms 等)的绑定更感兴趣,那么就说吧!) 。

I suggest something like:

while True:
    while queue:
        queue.pop()()

For that to work, however, you need to have the event system put callable events onto the queue.

(If you are more interested in a specific binding to a specific framework, such as GTK, Qt, WxWidgets, NCurses, Cocoa, Winforms, whatever, then say that!).

滥情稳全场 2024-12-03 06:01:47

libev 可作为 pyev 模块用于 Python:http://code. google.com/p/pyev/

libev is available for python as pyev module: http://code.google.com/p/pyev/

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