class documentation

class Client:

View In Hierarchy

Client for accessing Temporal.

Most users will use connect to create a client. The service property provides access to a raw gRPC client. To create another client, like for a different namespace, Client may be directly instantiated with a service of another.

Async Static Method connect Connect to a Temporal server.
Method __init__ Create a Temporal client from a workflow service.
Method config Config, as a dictionary, used to create this client.
Async Method execute_workflow Start a workflow and wait for completion.
Method get_async_activity_handle Get an async activity handle.
Method get_workflow_handle Get a workflow handle to an existing workflow by its ID.
Method get_workflow_handle_for Get a typed workflow handle to an existing workflow by its ID.
Async Method start_workflow Start a workflow and return its handle.
Property data_converter Data converter used by this client.
Property identity Identity used in calls by this client.
Property namespace Namespace used in calls by this client.
Property service Raw gRPC service for this client.
Instance Variable _config Undocumented
Instance Variable _impl Undocumented
Instance Variable _type_lookup Undocumented
@staticmethod
async def connect(target_host: str, *, namespace: str = 'default', data_converter: temporalio.converter.DataConverter = temporalio.converter.default(), interceptors: Iterable[Union[Interceptor, Callable[[OutboundInterceptor], OutboundInterceptor]]] = [], default_workflow_query_reject_condition: Optional[temporalio.common.QueryRejectCondition] = None, tls: Union[bool, TLSConfig] = False, retry_config: Optional[RetryConfig] = None, static_headers: Mapping[str, str] = {}, identity: Optional[str] = None) -> Client:

Connect to a Temporal server.

Parameters
target_host:strhost:port for the Temporal server. For local development, this is often "localhost:7233".
namespace:strNamespace to use for client calls.
data_converter:temporalio.converter.DataConverterData converter to use for all data conversions to/from payloads.
interceptors:Iterable[Union[Interceptor, Callable[[OutboundInterceptor], OutboundInterceptor]]]

Set of interceptors that are chained together to allow intercepting of client calls. The earlier interceptors wrap the later ones.

Any interceptors that also implement temporalio.worker.Interceptor will be used as worker interceptors too so they should not be given when creating a worker.

default_workflow_query_reject_condition:Optional[temporalio.common.QueryRejectCondition]The default rejection condition for workflow queries if not set during query. See WorkflowHandle.query for details on the rejection condition.
tls:Union[bool, TLSConfig]If false, the default, do not use TLS. If true, use system default TLS configuration. If TLS configuration present, that TLS configuration will be used.
retry_config:Optional[RetryConfig]Retry configuration for direct service calls (when opted in) or all high-level calls made by this client (which all opt-in to retries by default). If unset, a default retry configuration is used.
static_headers:Mapping[str, str]Static headers to use for all calls to the server.
identity:Optional[str]Identity for this client. If unset, a default is created based on the version of the SDK.
def __init__(self, service: temporalio.workflow_service.WorkflowService, *, namespace: str = 'default', data_converter: temporalio.converter.DataConverter = temporalio.converter.default(), interceptors: Iterable[Union[Interceptor, Callable[[OutboundInterceptor], OutboundInterceptor]]] = [], default_workflow_query_reject_condition: Optional[temporalio.common.QueryRejectCondition] = None):

Create a Temporal client from a workflow service.

See connect for details on the parameters.

def config(self) -> ClientConfig:

Config, as a dictionary, used to create this client.

This makes a shallow copy of the config each call.

@overload
async def execute_workflow(self, workflow: MethodAsyncNoParam[SelfType, ReturnType], *, id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> ReturnType:
@overload
async def execute_workflow(self, workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType], arg: ParamType, *, id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> ReturnType:
@overload
async def execute_workflow(self, workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]], *, args: Iterable[Any], id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> ReturnType:
@overload
async def execute_workflow(self, workflow: str, arg: Any = temporalio.common._arg_unset, *, args: Iterable[Any] = [], id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> Any:

Start a workflow and wait for completion.

This is a shortcut for start_workflow + WorkflowHandle.result.

@overload
def get_async_activity_handle(self, *, workflow_id: str, run_id: Optional[str], activity_id: str) -> AsyncActivityHandle:
@overload
def get_async_activity_handle(self, *, task_token: bytes) -> AsyncActivityHandle:

Get an async activity handle.

Either the workflow_id, run_id, and activity_id can be provided, or a singular task_token can be provided.

Parameters
workflow_id:Optional[str]Workflow ID for the activity. Cannot be set if task_token is set.
run_id:Optional[str]Run ID for the activity. Cannot be set if task_token is set.
activity_id:Optional[str]ID for the activity. Cannot be set if task_token is set.
task_token:Optional[bytes]Task token for the activity. Cannot be set if any of the id parameters are set.
Returns
AsyncActivityHandleA handle that can be used for completion or heartbeat.
def get_workflow_handle(self, workflow_id: str, *, run_id: Optional[str] = None, first_execution_run_id: Optional[str] = None) -> WorkflowHandle[Any, Any]:

Get a workflow handle to an existing workflow by its ID.

Parameters
workflow_id:strWorkflow ID to get a handle to.
run_id:Optional[str]Run ID that will be used for all calls.
first_execution_run_id:Optional[str]First execution run ID used for cancellation and termination.
Returns
WorkflowHandle[Any, Any]The workflow handle.
def get_workflow_handle_for(self, workflow: Union[MethodAsyncNoParam[SelfType, ReturnType], MethodAsyncSingleParam[SelfType, Any, ReturnType]], workflow_id: str, *, run_id: Optional[str] = None, first_execution_run_id: Optional[str] = None) -> WorkflowHandle[SelfType, ReturnType]:

Get a typed workflow handle to an existing workflow by its ID.

This is the same as get_workflow_handle but typed. Note, the workflow type given is not validated, it is only for typing.

Parameters
workflow:Union[MethodAsyncNoParam[SelfType, ReturnType], MethodAsyncSingleParam[SelfType, Any, ReturnType]]The workflow run method to use for typing the handle.
workflow_id:strWorkflow ID to get a handle to.
run_id:Optional[str]Run ID that will be used for all calls.
first_execution_run_id:Optional[str]First execution run ID used for cancellation and termination.
Returns
WorkflowHandle[SelfType, ReturnType]The workflow handle.
@overload
async def start_workflow(self, workflow: MethodAsyncNoParam[SelfType, ReturnType], *, id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> WorkflowHandle[SelfType, ReturnType]:
@overload
async def start_workflow(self, workflow: MethodAsyncSingleParam[SelfType, ParamType, ReturnType], arg: ParamType, *, id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> WorkflowHandle[SelfType, ReturnType]:
@overload
async def start_workflow(self, workflow: Callable[Concatenate[SelfType, MultiParamSpec], Awaitable[ReturnType]], *, args: Iterable[Any], id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> WorkflowHandle[SelfType, ReturnType]:
@overload
async def start_workflow(self, workflow: str, arg: Any = temporalio.common._arg_unset, *, args: Iterable[Any] = [], id: str, task_queue: str, execution_timeout: Optional[timedelta] = None, run_timeout: Optional[timedelta] = None, task_timeout: Optional[timedelta] = None, id_reuse_policy: temporalio.common.WorkflowIDReusePolicy = temporalio.common.WorkflowIDReusePolicy.ALLOW_DUPLICATE, retry_policy: Optional[temporalio.common.RetryPolicy] = None, cron_schedule: str = '', memo: Optional[Mapping[str, Any]] = None, search_attributes: Optional[temporalio.common.SearchAttributes] = None, start_signal: Optional[str] = None, start_signal_args: Iterable[Any] = []) -> WorkflowHandle[Any, Any]:

Start a workflow and return its handle.

Parameters
workflow:Union[str, Callable[..., Awaitable[Any]]]String name or class method decorated with @workflow.run for the workflow to start.
arg:AnySingle argument to the workflow.
args:Iterable[Any]Multiple arguments to the workflow. Cannot be set if arg is.
id:strUnique identifier for the workflow execution.
task_queue:strTask queue to run the workflow on.
execution_timeout:Optional[timedelta]Total workflow execution timeout including retries and continue as new.
run_timeout:Optional[timedelta]Timeout of a single workflow run.
task_timeout:Optional[timedelta]Timeout of a single workflow task.
id_reuse_policy:temporalio.common.WorkflowIDReusePolicyHow already-existing IDs are treated.
retry_policy:Optional[temporalio.common.RetryPolicy]Retry policy for the workflow.
cron_schedule:strSee https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
memo:Optional[Mapping[str, Any]]Memo for the workflow.
search_attributes:Optional[temporalio.common.SearchAttributes]Search attributes for the workflow.
start_signal:Optional[str]If present, this signal is sent as signal-with-start instead of traditional workflow start.
start_signal_args:Iterable[Any]Arguments for start_signal if start_signal present.
Returns
WorkflowHandle[Any, Any]A workflow handle to the started/existing workflow.
Raises
RPCErrorWorkflow could not be started.

Data converter used by this client.

@property
identity: str =

Identity used in calls by this client.

@property
namespace: str =

Namespace used in calls by this client.

Raw gRPC service for this client.

_config =

Undocumented

_impl =

Undocumented

_type_lookup =

Undocumented