node.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Pyrlang 作者: esl 项目源码 文件源码
def dist_command(self, receiver_node: str, message: tuple) -> None:
        """ Locate the connection to the given node (a string).
            Place a tuple crafted by the caller into message box for Erlang
            distribution socket. It will pick up and handle the message whenever
            possible.

            :param receiver_node: Name of a remote node
            :param message: A crafted tuple with command name and some more
                values
        """
        if receiver_node not in self.dist_nodes_:
            LOG("Node: connect to node", receiver_node)
            handler = self.dist_.connect_to_node(
                this_node=self,
                remote_node=receiver_node)

            if handler is None:
                raise NodeException("Node not connected %s" % receiver_node)

            # block until connected, and get the connected message
            LOG("Node: wait for 'node_connected'")
            # msg = self.inbox_.receive_wait(
            #     filter_fn=lambda m: m[0] == 'node_connected'
            # )
            while receiver_node not in self.dist_nodes_:
                gevent.sleep(0.1)

            LOG("Node: connected")

        conn = self.dist_nodes_[receiver_node]
        conn.inbox_.put(message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号