class documentation
Activity environment for testing activities.
This environment is used for running activity code that can access the
functions in the temporalio.activity
module. Use run
to
run an activity function or any function within an activity context.
Method | __init__ |
Create an ActivityEnvironment for running activity code. |
Method | cancel |
Cancel the activity. |
Method | run |
Run the given callable in an activity context. |
Method | worker |
Notify the activity that the worker is shutting down. |
Instance Variable | info |
The info that is returned from temporalio.activity.info function. |
Instance Variable | metric |
Metric meter set on the activity context. This must be set before run . Changes after the activity has started do not take effect. Default is noop. |
Instance Variable | on |
Function called on each heartbeat invocation by the activity. |
Instance Variable | payload |
Payload converter set on the activity context. This must be set before run . Changes after the activity has started do not take effect. |
Instance Variable | _activities |
Undocumented |
Instance Variable | _cancelled |
Undocumented |
Instance Variable | _worker |
Undocumented |
def run(self, fn:
Callable[ _Params, _Return]
, *args: _Params.args
, **kwargs: _Params.kwargs
) -> _Return
:
(source)
¶
Run the given callable in an activity context.
Parameters | |
fn:Callable[ | The function/callable to run. |
*args:_Params.args | All positional arguments to the callable. |
**kwargs:_Params.kwargs | All keyword arguments to the callable. |
Returns | |
_Return | The callable's result. |
Metric meter set on the activity context. This must be set
before run
. Changes after the activity has started do not
take effect. Default is noop.
Payload converter set on the activity context. This
must be set before run
. Changes after the activity has
started do not take effect.