temporalio.activity
| Class | |
Provides the reasons for the activity's cancellation. Cancellation details are set once and do not change once set. |
| Class | |
Information about the running activity. |
| Class | |
Adapter that adds details to the log about the running activity. |
| Function | cancellation |
Cancellation details of the current activity, if any. Once set, cancellation details do not change. |
| Function | client |
Return a Temporal Client for use in the current activity. |
| Function | defn |
Decorator for activity functions. |
| Function | heartbeat |
Send a heartbeat for the current activity. |
| Function | in |
Whether the current code is inside an activity. |
| Function | info |
Current activity's info. |
| Function | is |
Whether a cancellation was ever requested on this activity. |
| Function | is |
Whether shutdown has been invoked on the worker. |
| Function | metric |
Get the metric meter for the current activity. |
| Function | payload |
Get the payload converter for the current activity. |
| Function | raise |
Raise an error that says the activity will be completed asynchronously. |
| Function | shield |
Context manager for synchronous multithreaded activities to delay cancellation exceptions. |
| Async Function | wait |
Asynchronously wait for this activity to get a cancellation request. |
| Function | wait |
Synchronously block while waiting for a cancellation request on this activity. |
| Async Function | wait |
Asynchronously wait for shutdown to be called on the worker. |
| Function | wait |
Synchronously block while waiting for shutdown to be called on the worker. |
| Variable | logger |
Logger that will have contextual activity details embedded. |
| Class | _ |
Undocumented |
| Class | _ |
Undocumented |
| Class | _ |
Undocumented |
| Exception | _ |
Undocumented |
| Variable | _current |
Undocumented |
Cancellation details of the current activity, if any. Once set, cancellation details do not change.
Return a Temporal Client for use in the current activity.
The client is only available in async def activities.
In tests it is not available automatically, but you can pass a client when creating a
temporalio.testing.ActivityEnvironment.
Decorator for activity functions.
Activities can be async or non-async.
| Parameters | |
fn:CallableType | None | The function to decorate. |
name:str | None | Name to use for the activity. Defaults to function __name__. This cannot be set if dynamic is set. |
nobool | If set to true, an exception will not be raised in synchronous, threaded activities upon cancellation. |
dynamic:bool | If true, this activity will be dynamic. Dynamic activities have to accept a single 'Sequence[RawValue]' parameter. This cannot be set to true if name is present. |
Send a heartbeat for the current activity.
Whether the current code is inside an activity.
| Returns | |
bool | True if in an activity, False otherwise. |
Current activity's info.
| Returns | |
Info | Info for the currently running activity. |
Whether a cancellation was ever requested on this activity.
| Returns | |
bool | True if the activity has had a cancellation request, False otherwise. |
Whether shutdown has been invoked on the worker.
| Returns | |
bool | True if shutdown has been called on the worker, False otherwise. |
Get the metric meter for the current activity.
Warning
This is only available in async or synchronous threaded activities. An error is raised on non-thread-based sync activities when trying to access this.
| Raises | |
RuntimeError | When not in an activity or in a non-thread-based synchronous activity. |
Raise an error that says the activity will be completed asynchronously.
Context manager for synchronous multithreaded activities to delay cancellation exceptions.
By default, synchronous multithreaded activities have an exception thrown inside when cancellation occurs. Code within a "with" block of this context manager will delay that throwing until the end. Even if the block returns a value or throws its own exception, if a cancellation exception is pending, it is thrown instead. Therefore users are encouraged to not throw out of this block and can surround this with a try/except if they wish to catch a cancellation.
This properly supports nested calls and will only throw after the last one.
This just runs the blocks with no extra effects for async activities or synchronous multiprocess/other activities.
Asynchronously wait for this activity to get a cancellation request.
Synchronously block while waiting for a cancellation request on this activity.
This is essentially a wrapper around threading.Event.wait.
Asynchronously wait for shutdown to be called on the worker.
Synchronously block while waiting for shutdown to be called on the worker.
This is essentially a wrapper around threading.Event.wait.
| Parameters | |
timeout:timedelta | float | None | Max amount of time to wait for shutdown to be called on the worker. |
Logger that will have contextual activity details embedded.