libmuscle.post_office module

class libmuscle.post_office.PostOffice[source]

Bases: libmuscle.mcp.transport_server.RequestHandler

A PostOffice is an object that holds messages to be retrieved.

A PostOffice holds outboxes with messages for receivers. It also acts as a request handler for incoming requests for messages.

Create a PostOffice.

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

Deposits a message into an outbox.

Parameters
  • receiver – Receiver of the message.

  • message – The message to deposit.

get_message(receiver: ymmsl.identity.Reference) bytes[source]

Get a message from a receiver’s outbox.

Used by servers to get messages that have been sent to another instance.

Parameters

receiver – The receiver of the message.

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

wait_for_receivers() None[source]

Waits until all outboxes are empty.