pyrlang.dist_proto.distribution¶
Distribution class is a separate running Task which owns its TCP connection.
- class pyrlang.dist_proto.distribution.ErlangDistribution(node_name, hidden=False, use_epmd=True, dist_port=0, dynamic_host=None)¶
Bases:
objectImplements network part of the EPMD registration and Erlang dist_proto protocol.
- node_name_¶
Node name, a string.
- dynamic_¶
The node got, or will get, its name from another node.
- name_pending_¶
The node has no name yet.
- host_¶
The host part of the node name.
- naming_lock_¶
One connection setup at a time while the node has no name.
- creation_¶
Creation of this incarnation of the node, part of every pid and reference it makes and of its handshake messages. Chosen here, before the first process exists, and never 0; the creation EPMD hands out later is not used (as for erl_interface nodes).
- connecting_: dict[str, Task[bool]]¶
Connection setups this node started, by peer name; everyone who wants that peer awaits the same task.
- pending_out_: dict[str, DistClientProtocol]¶
Outgoing connections whose handshake is not finished, by peer.
- superseded_: set[str]¶
Peers whose own connection to us was preferred over our setup (simultaneous connect).
- async start_server()¶
Start listening for incoming connections.
- async start_distribution()¶
Start listening for other nodes and, unless the node does not use EPMD, register in the local EPMD.
- Raises:
OSError – the listening port is in use
EPMDConnectionError – EPMD cannot be reached or refuses the node name
- async run_dist_server()¶
Start listening for connections from other nodes.
- disconnect_epmd()¶
Finish EPMD connection, this will remove the node from the list of available nodes on EPMD
- destroy()¶
Stop listening and leave EPMD. Safe to call twice.
- async connect_to_node(local_node, remote_node, address=None)¶
Query EPMD where is the node, connect and run the handshake. Concurrent calls for one node share one connection setup.
- Parameters:
- Returns:
True once the connection is established; False if EPMD does not know the node
- Raises:
DistributionError – the handshake failed or timed out
EPMDConnectionError – the node’s EPMD cannot be asked
NodeException – this node does not use EPMD and no address was given
- Return type:
- accept_pending(peer_name)¶
Decide what an incoming connection from
peer_nameis told while this node may be connecting to that peer itself, asnet_kerneldoes foraccept_pending.- Returns:
the status to send:
ok,ok_simultaneous(our own attempt is dropped) ornok(our attempt goes on, the incoming connection must be closed)- Return type: