libmuscle.post_office module

class libmuscle.post_office.PostOffice[source]

Bases: 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.

deposit(receiver: 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: 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.