推荐的 Python 发布/订阅/调度模块? [英] Recommended Python publish/subscribe/dispatch module?

查看:171
本文介绍了推荐的 Python 发布/订阅/调度模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 PyPubSub:

Pypubsub 提供了一种简单的方法要解耦的 Python 应用程序它的组成部分:你的部分应用程序可以发布消息(使用或没有数据)和其他部分可以订阅/接收它们.这允许消息发件人"和消息听众"不知道每个其他:

Pypubsub provides a simple way for your Python application to decouple its components: parts of your application can publish messages (with or without data) and other parts can subscribe/receive them. This allows message "senders" and message "listeners" to be unaware of each other:

  • 一个不需要导入另一个
  • 发件人不需要知道
    • 谁"收到消息,
    • 听众将如何处理数据,
    • 或者即使任何侦听器将获取消息数据.

    这是一个很好的实施工具模型-视图-控制器架构或任何类似的架构促进其组件的解耦.

    This is a great tool for implementing a Model-View-Controller architecture or any similar architecture that promotes decoupling of its components.

    网络上似乎有很多用于发布/订阅的 Python 模块,从 PyPubSub 到 PyDispatcher 到简单的家常菜"类.

    There seem to be quite a few Python modules for publishing/subscribing floating around the web, from PyPubSub, to PyDispatcher to simple "home-cooked" classes.

    在比较不同的不同模块时是否有特定的优点和缺点?对哪些模块进行了基准测试和比较?

    Are there specific advantages and disadvantages when comparing different different modules? Which sets of modules have been benchmarked and compared?

    提前致谢

    推荐答案

    PyDispatcherDjango 并且它非常适合我(我猜对于整个 Django 社区).

    PyDispatcher is used heavily in Django and it's working perfectly for me (and for whole Django community, I guess).

    我记得,有一些性能问题:

    As I remember, there are some performance issues:

    • PyDispatcher 进行的参数检查很慢.
    • 未使用的连接会产生不必要的开销.

    AFAIK 您不太可能在中小型应用程序中遇到此问题.因此,这些问题可能与您无关.如果你认为你需要每一磅的性能(过早的优化是万恶之源!),你可以看看在 Django 中对 PyDispatcher 所做的修改.

    AFAIK it's very unlikely you will run into this issues in a small-to-medium sized application. So these issues may not concern you. If you think you need every pound of performance (premature optimization is the root of all evil!), you can look at modifications done to PyDispatcher in Django.

    希望这会有所帮助.

    这篇关于推荐的 Python 发布/订阅/调度模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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