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)
评论列表
文章目录