libmuscle.mpp_server module

class libmuscle.mpp_server.MPPRequestHandler(post_office: PostOffice)[source]

Bases: RequestHandler

Handles peer protocol requests.

This accepts peer protocol message requests and responds to them by getting messages from a PostOffice.

handle_request(request: bytes) bytes[source]

Handle a request.

This receives an MCP request and handles it by blocking until the requested message is available, then returning it.

Parameters:

request – A received request

Returns:

An encoded response

class libmuscle.mpp_server.MPPServer[source]

Bases: object

Serves MPP requests.

This manages a collection of servers for different protocols and a PostOffice that stores outgoing messages.

deposit(receiver: Reference, message: bytes) None[source]

Deposits a message for the receiver to retrieve.

Parameters:
  • receiver – Receiver of the message.

  • message – The message to deposit.

get_locations() List[str][source]

Returns a list of locations that we can be reached at.

These locations are of the form ‘protocol:location’, where the protocol name does not contain a colon and location may be an arbitrary string.

Returns:

A list of strings describing network locations.

shutdown() None[source]

Shut down all servers.

wait_for_receivers() None[source]

Waits for all deposited messages to have been received.