ServiceClient

class bpod_core.ipc.ServiceClient

Bases: ServiceBase, Generic

A client for communicating with ServiceHost.

Parameters:
  • service_type (str) – The service type to discover or connect to.

  • address (str, optional) – The direct connection address for the REQ channel, by default None.

  • event_handler (Callable, optional) – A callback to handle PUB messages, by default None.

  • discovery_timeout (float, default: 10.0) – Timeout in seconds for service discovery.

  • txt_properties (dict, optional) – Properties for service filtering during discovery, by default None.

  • default_data_type (type, optional) – The default data type for incoming messages.

  • remote (bool, optional) – Whether to use Zeroconf for discovering remote services, by default True.

close()

Close the client and clean up resources.

Return type:

None

request(request_data, reply_type=None)

Send a generic request to the server.

Parameters:
  • request_data (Any) – The request payload.

  • reply_type (type, optional) – Override the expected reply type.

Returns:

The deserialized reply from the server. If reply_type is given, returns an instance of reply_type; otherwise returns an instance of default_data_type defined during instantiation of the class.

Return type:

Any

Raises:
  • RemoteError – If an error occurred on the host side.

  • ServiceError – If the host sent an unexpected reply kind.

property address_req: str

The address for the REQ channel.

property address_sub: str

The address for the SUB channel.

is_local: bool

Whether the client is connected to a service on localhost.