class documentation

Runtime for Temporal Python SDK.

Most users are encouraged to use default. It can be set with set_default. Every time a new runtime is created, a new internal thread pool is created.

Warning

Create a separate runtime in each process after forking. Creating a runtime before forking can retain inherited native memory and file descriptors in the child until it exits, even after the inherited runtime is garbage collected. Use prevent_default and set_default to control when each process creates its default runtime.

Class Method default Get the default runtime, creating if not already created. If prevent_default is called before this method it will raise a RuntimeError instead of creating a default runtime.
Class Method prevent_default Prevent default from lazily creating a Runtime.
Static Method set_default Set the default runtime to the given runtime.
Method __init__ Create a runtime with the provided configuration.
Property metric_meter Metric meter for this runtime. This is a no-op metric meter if no metrics were configured.
Instance Variable _core_runtime Undocumented
Instance Variable _metric_meter Undocumented
def default(cls) -> Runtime: (source)

Get the default runtime, creating if not already created. If prevent_default is called before this method it will raise a RuntimeError instead of creating a default runtime.

If the default runtime needs to be different, it should be done with set_default before this is called or ever used.

Returns
RuntimeThe default runtime.
def prevent_default(cls): (source)

Prevent default from lazily creating a Runtime.

Raises a RuntimeError if a default Runtime has already been created.

Explicitly setting a default runtime with set_default bypasses this setting and future calls to default will return the provided runtime.

def set_default(runtime: Runtime, *, error_if_already_set: bool = True): (source)

Set the default runtime to the given runtime.

This should be called before any Temporal client is created, but can change the existing one. Any clients and workers created with the previous runtime will stay on that runtime.

Parameters
runtime:RuntimeThe runtime to set.
error_if_already_set:boolIf True and default is already set, this will raise a RuntimeError.
def __init__(self, *, telemetry: TelemetryConfig, worker_heartbeat_interval: timedelta | None = timedelta(seconds=60), disable_environment_info: bool = False): (source)

Create a runtime with the provided configuration.

Each new runtime creates a new internal thread pool, so use sparingly.

Parameters
telemetry:TelemetryConfigTelemetry configuration when not supplying runtime_options.
worker_heartbeat_interval:timedelta | NoneInterval for worker heartbeats. None disables heartbeating. Interval must be between 1s and 60s.
disable_environment_info:boolWhether to omit runtime, hosting, and platform information from worker heartbeats.
Raises
ValueErrorIf both `runtime_options is a negative value.

Metric meter for this runtime. This is a no-op metric meter if no metrics were configured.

_core_runtime = (source)

Undocumented

_metric_meter = (source)

Undocumented