p2pfl.communication.protocols.memory.memory_server moduleΒΆ

In-memory server.

class p2pfl.communication.protocols.memory.memory_server.InMemoryServer(addr, gossiper, neighbors, commands=None)[source]ΒΆ

Bases: object

Implementation of the server side of an in-memory communication protocol.

Parameters:
  • addr (str) – Address of the server.

  • gossiper (Gossiper) – Gossiper instance.

  • neighbors (InMemoryNeighbors) – Neighbors instance.

  • commands (Optional[List[Command]]) – List of commands to be executed by the server.

add_command(cmds)[source]ΒΆ

Add a command.

Parameters:

cmds (Union[Command, List[Command]]) – Command or list of commands to be added.

Return type:

None

disconnect(request)[source]ΒΆ

In-memory service. It is called when a node disconnects from another.

Parameters:

request (Dict[str, Any]) – Request message.

Return type:

None

handshake(request)[source]ΒΆ

In-memory service. It is called when a node connects to another.

Parameters:

request (Dict[str, Any]) – Request message.

Return type:

Dict[str, Any]

is_running()[source]ΒΆ

Check if the server is running.

Return type:

bool

Returns:

True if the server is running, False otherwise.

send_message(request)[source]ΒΆ

In-memory service. It is called when a node sends a message to another.

Parameters:

request (Dict[str, Any]) – Request message

Return type:

Dict[str, Any]

send_weights(request)[source]ΒΆ

In-memory service. It is called when a node sends weights to another.

Parameters:

request (Dict[str, Any]) – Request message.

Return type:

Dict[str, Any]

start(wait=False)[source]ΒΆ

Start the in-memory server.

Parameters:

wait (bool) – If True, wait for termination.

Return type:

None

stop()[source]ΒΆ

Stop the in-memory server.

Return type:

None

wait_for_termination()[source]ΒΆ

Wait for termination.

Return type:

None