开发者

Successful use of pidbox.Mailbox?

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(cha开发者_Python百科nnel = 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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜