agentscope.rpc.rpc_object module

A proxy object which represent a object located in a rpc server.

agentscope.rpc.rpc_object.get_public_methods(cls: type) list[str][源代码]

Get all public methods of the given class.

class agentscope.rpc.rpc_object.RpcObject(cls: type, oid: str, host: str, port: int, connect_existing: bool = False, max_pool_size: int = 8192, max_expire_time: int = 7200, max_timeout_seconds: int = 5, local_mode: bool = True, retry_strategy: ~agentscope.rpc.retry_strategy.RetryBase | dict = <agentscope.rpc.retry_strategy.RetryFixedTimes object>, configs: dict | None = None)[源代码]

基类:ABC

A proxy object which represent an object located in an Rpc server.

备注

When to_dist is called on an object or when using the to_dist parameter to create an object, the object is moved to an Rpc server, and an RpcObject instance is left behind in the local process. The RpcObject will automatically forward all public method invocations to the original object in the rpc server.

__init__(cls: type, oid: str, host: str, port: int, connect_existing: bool = False, max_pool_size: int = 8192, max_expire_time: int = 7200, max_timeout_seconds: int = 5, local_mode: bool = True, retry_strategy: ~agentscope.rpc.retry_strategy.RetryBase | dict = <agentscope.rpc.retry_strategy.RetryFixedTimes object>, configs: dict | None = None) None[源代码]

Initialize the rpc object.

参数:
  • cls (type) – The class of the object in the rpc server.

  • oid (str) – The id of the object in the rpc server.

  • host (str) – The host of the rpc server.

  • port (int) – The port of the rpc server.

  • connect_existing (bool, defaults to False) – Set to True, if the object is already running on the server.

  • max_pool_size (int, defaults to 8192) – Max number of task results that the server can accommodate.

  • max_expire_time (int, defaults to 7200) – Max expire time for task results.

  • max_timeout_seconds (int, defaults to 5) – Max timeout seconds for the rpc call.

  • local_mode (bool, defaults to True) – Whether the started gRPC server only listens to local requests.

  • retry_strategy (Union[RetryBase, dict], defaults to _DEAFULT_RETRY_STRATEGY) – The retry strategy for async rpc call.

  • configs (dict, defaults to None) – The configs for the agent. Generated by RpcMeta. Don’t use this arg manually.

create(configs: dict) None[源代码]

create the object on the rpc server.

stop() None[源代码]

Stop the RpcAgent and the rpc server.