libmuscle.mcp.direct_client module

class libmuscle.mcp.direct_client.DirectClient(instance_id: Reference, location: str)[source]

Bases: Client

A client that connects to an MCP server directly.

This client connects to a DirectServer, and together they provide communication within in the same process.

Create a DirectClient for a given location.

The client will connect to this location and be able to request messages from any instance and port represented by it.

Parameters
  • instance_id – Our instance id.

  • location – A location string.

static can_connect_to(location: str) bool[source]

Whether DirectClient can connect to the given location.

Parameters

location – The location to potentially connect to.

Returns

True iff a DirectClient can connect to this location.

close() None[source]

Closes any resources needed.

receive(receiver: Reference) bytes[source]

Receive a message from a port this client connects to.

Parameters

receiver – The receiving (local) port.

Returns

The received message.