mahos.node.client.NodeClient#

class mahos.node.client.NodeClient(gconf: dict, name: NodeName, context: Context | None = None, prefix: str | None = None)#

Client to use Node’s function.

Parameters:
  • gconf – global config dict.

  • name – name of target node.

  • context – communication context.

  • prefix – name prefix for logger.

Variables:
  • conf – target node’s local config.

  • ctx – communication context.

  • logger – configured logger.

Important methods

add_req(gconf: dict, endpoint: str = 'rep_endpoint', rep_type: Type[Reply] | None = None) Requester#

Add and return a Requester for endpoint.

Request timeout (req_timeout_ms) is searched from self.conf or gconf.

add_sub(topic_handler_types: list[tuple[bytes | str, Optional[mahos.util.typing.SubHandler], Optional[Type[mahos.msgs.common_msgs.Message]]]], endpoint: str = 'pub_endpoint') list[mahos.util.typing.MessageGetter]#

Subscribe to topics from endpoint registering the handlers.

To do so, add and start a SubWorker for this client.

Parameters:

topic_handler_types – List of (topic, handler, msg_type), (topic, handler) or topic. In second case, msg_type is considered None. In the last case, handler and msg_type are considered None.

Returns:

List of MessageGetters. Length is same as topic_handler_types.

Other methods

__init__(gconf, name[, context, prefix])

close([close_ctx])

Close this client.

full_name()

Get full name: (prefix->)ClientClassName(target_node.joined_name())

get_status()

Get status of node: default implementation is void and raises NotImplementedError.

is_up()

Check if the target is up.

joined_name()

Get target node name as single string 'hostname::nodename'.

name()

Get target node name as a tuple (hostname, nodename).

start_subworker(subw)

Start a thread for a SubWorker.

wait()

Wait until the target is ready.

Attributes

M

The module that defines message types for target node.