class ActivityHandle(Generic[
Constructor: ActivityHandle(client, id, run_id, result_type)
Handle representing an activity execution not started by a workflow.
Warning
This API is experimental.
| Method | __init__ |
Create activity handle. |
| Async Method | cancel |
Request cancellation of the activity. |
| Async Method | describe |
Describe the activity execution. |
| Async Method | pause |
Pause the activity. |
| Async Method | restore |
Restore the activity's options to the ones it was created with. |
| Async Method | result |
Wait for result of the activity. |
| Async Method | terminate |
Terminate the activity execution immediately. |
| Async Method | unpause |
Unpause the activity, allowing it to be scheduled or retried again. |
| Async Method | update |
Update the activity's options. |
| Property | id |
ID of the activity. |
| Property | run |
Run ID of the activity. |
| Async Method | _poll |
Poll for activity result until it's available. |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _id |
Undocumented |
| Instance Variable | _known |
Undocumented |
| Instance Variable | _result |
Undocumented |
| Instance Variable | _run |
Undocumented |
| Property | _data |
Undocumented |
Client, id: str, *, run_id: str | None = None, result_type: type | None = None):
(source)
¶
Create activity handle.
str | None = None, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None):
(source)
¶
Request cancellation of the activity.
Warning
This API is experimental.
Requesting cancellation of an activity does not automatically transition the activity to
canceled status. If the activity is heartbeating, a exceptions.CancelledError
exception will be raised when receiving the heartbeat response; if the activity allows this
exception to bubble out, the activity will transition to canceled status. If the activity it
is not heartbeating, this method will have no effect on activity status.
| Parameters | |
reason:str | None | Reason for the cancellation. Recorded and available via describe. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
bool = False, include_outcome: bool = False, include_heartbeat_details: bool = False, include_last_failure: bool = False, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None) -> ActivityExecutionDescription:
(source)
¶
Describe the activity execution.
Warning
This API is experimental.
| Parameters | |
includebool | Include activity input in the response if available. |
includebool | Include activity outcome in the response if available. |
includebool | Include heartbeat details in the response if available. |
includebool | Include last failure in the response if available. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
| Returns | |
ActivityExecutionDescription | Activity execution description. |
str | None = None, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None):
(source)
¶
Pause the activity.
A paused activity is not scheduled or retried until it is unpaused via
unpause.
Warning
This API is experimental.
| Parameters | |
reason:str | None | Reason for pausing. Recorded and available via describe. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None) -> ActivityExecutionOptions:
(source)
¶
Restore the activity's options to the ones it was created with.
This is a separate call rather than an option on
update_options because the server rejects a request that
combines the restore flag with any other option.
Warning
This API is experimental.
| Parameters | |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
| Returns | |
ActivityExecutionOptions | The activity options as resolved by the server after the restore. |
Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None) -> ReturnType:
(source)
¶
Wait for result of the activity.
Warning
This API is experimental.
The result may already be known if this method has been called before, in which case no network call is made. Otherwise the result will be polled for until it is available.
| Parameters | |
rpcMapping[ | Headers used on the RPC call. Keys here override client-level RPC metadata keys. |
rpctimedelta | None | Optional RPC deadline to set for each RPC call. Note: this is the timeout for each RPC call while polling, not a timeout for the function as a whole. If an individual RPC times out, it will be retried until the result is available. |
| Returns | |
ReturnType | The result of the activity. |
| Raises | |
ActivityFailureError | If the activity completed with a failure. |
RPCError | Activity result could not be fetched for some reason. |
str | None = None, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None):
(source)
¶
Terminate the activity execution immediately.
Warning
This API is experimental.
Termination does not reach the worker and the activity code cannot react to it. A terminated activity may have a running attempt and will be requested to be canceled by the server when it heartbeats.
| Parameters | |
reason:str | None | Reason for the termination. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
str | None = None, jitter: timedelta | None = None, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None):
(source)
¶
Unpause the activity, allowing it to be scheduled or retried again.
Warning
This API is experimental.
| Parameters | |
reason:str | None | Reason for unpausing. Recorded on the server. |
jitter:timedelta | None | If set, the activity starts at a random time within this duration rather than immediately. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
Sequence[ ActivityOptionsUpdate[ Any]], *, rpc_metadata: Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None) -> ActivityExecutionOptions:
(source)
¶
Update the activity's options.
Only the options named by updates are changed; anything not named is
left as-is. An update created with
ActivityOptionsKey.value_unset clears that option.
Each option may be named at most once; naming the same option twice
raises ValueError.
Warning
This API is experimental.
| Parameters | |
updates:Sequence[ | Options to change, built from ActivityOptionsKeys. |
rpcMapping[ | Headers used on the RPC call. |
rpctimedelta | None | Optional RPC deadline to set for the RPC call. |
| Returns | |
ActivityExecutionOptions | The activity options as resolved by the server after the update. |
| Raises | |
ValueError | If updates is empty or names the same option twice. |
Mapping[ str, str | bytes] = {}, rpc_timeout: timedelta | None = None):
(source)
¶
Poll for activity result until it's available.