pidbox.Mailbox使用成功吗?

发布于 2024-10-27 05:55:11 字数 1486 浏览 9 评论 0原文

有人使用过 pidbox.Mailbox 吗?

我正在尝试做与该示例类似的事情,但该文档已经过时了。我已经设法得到一些东西,将消息发布到 django 传输,但从那里它们从未被成功接收。

我希望有人知道如何使用它,并且可以向我展示如何成功呼叫/投射的示例。

这是我所拥有的(虚拟节点实际上什么也不做,只是打印或列出):

    #node/server
    mailbox = pidbox.Mailbox("test", type="direct")
    connection  = BrokerConnection(transport="django")

    bound = mailbox(connection)

    state = {"node": DummyNode(),
                "connection": connection
        }

    node = bound.Node(state = state)

    @node.handler
    def list( state, **kwargs):
        print 'list called'
        return state["node"].list()
    @node.handler
    def connection_info(state, **kwargs):
        return {"connection": state["connection"].info()}
    @node.handler
    def print_msg(state, **kwargs):
        print 'Node handler!'
        state["node"].print_msg(kwargs)


    consumer = node.listen(channel = connection.channel())
    try:
        while not self.killed:
            print 'Consumer Waiting'
            connection.drain_events()
    finally:
        consumer.cancel()

和一个简单的客户端。

#client:    

mailbox = pidbox.Mailbox("test", type="direct")
connection  = BrokerConnection(transport="django")
bound = mailbox(connection)

bound.cast(["localhost"], "print_msg", {'msg' : 'Message for you'})
info = bound.call(["test_application"],"list", callback=callback)

Has anyone used pidbox.Mailbox ?

I am attempting to do something similar to that example, but that documentation is way out of date. I have managed to get something that pubishes messages to a django transport but from there they never are successfuly received.

I was hoping that someone knows how to use this, and could show me an example of how to successfuly call/cast.

Here is what I have(dummy node really does nothing just prints or lists):

    #node/server
    mailbox = pidbox.Mailbox("test", type="direct")
    connection  = BrokerConnection(transport="django")

    bound = mailbox(connection)

    state = {"node": DummyNode(),
                "connection": connection
        }

    node = bound.Node(state = state)

    @node.handler
    def list( state, **kwargs):
        print 'list called'
        return state["node"].list()
    @node.handler
    def connection_info(state, **kwargs):
        return {"connection": state["connection"].info()}
    @node.handler
    def print_msg(state, **kwargs):
        print 'Node handler!'
        state["node"].print_msg(kwargs)


    consumer = node.listen(channel = connection.channel())
    try:
        while not self.killed:
            print 'Consumer Waiting'
            connection.drain_events()
    finally:
        consumer.cancel()

And a simple client.

#client:    

mailbox = pidbox.Mailbox("test", type="direct")
connection  = BrokerConnection(transport="django")
bound = mailbox(connection)

bound.cast(["localhost"], "print_msg", {'msg' : 'Message for you'})
info = bound.call(["test_application"],"list", callback=callback)

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

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

发布评论

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

评论(1

很糊涂小朋友 2024-11-03 05:55:11

答案显然是否定的。如果您看到这篇文章,我强烈建议您自己写一篇。 pidbox 的文档太少,而且现有的文档已经过时了。

The answer to this is apparently no. If you come across this post I highly recommend writing your own. There is too little documentation for pidbox, and the documentation that is there is out of date.

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