class documentation

Client wrapper for per-workflow time skipping.

Warning

This API is experimental and unstable.

Wraps a client with an interceptor that stamps a TimeSkippingConfig on every workflow started through client.

Workflows:

Schedules:

In tests, the same functionality is available via WorkflowEnvironment.start_time_skipping_v2. Use TimeSkipper directly outside test environments.

Method __init__ Create a time skipper.
Method config.setter Undocumented
Async Method fast_forward Issue a fast-forward on a workflow and wait for it to complete.
Async Method fast_forward_schedule Advance a schedule's virtual clock and wait for the fast-forward.
Async Method get_current_time Get a workflow's current virtual time.
Async Method get_schedule_current_time Get a schedule's current virtual time.
Async Method get_schedule_time_skipping_info Fetch a schedule's TimeSkippingInfo via DescribeSchedule.
Async Method get_time_skipping_info Fetch a workflow's TimeSkippingInfo via DescribeWorkflowExecution.
Async Method poll_schedule_fast_forward Wait for a fast-forward on a schedule to finish.
Async Method set_schedule_time_skipping_config Replace a schedule's time-skipping configuration.
Method with_time_skipping_disabled Suspend time-skipping config stamping on newly-started workflows within the block.
Property client Client that stamps time-skipping config on every started workflow.
Property config Configuration applied to future start_workflow calls.
Static Method _schedule_fast_forward_timeout_message Undocumented
Async Method _poll_fast_forward_completion Long-poll for a bounded fast-forward to complete.
Async Method _update_time_skipping_config Replace the stored time-skipping config for a running workflow.
Async Method _wait_for_unbounded_fast_forward_completion Enable unbounded time skipping and wait for the workflow to terminate.
Instance Variable _client Undocumented
Instance Variable _config Undocumented
Instance Variable _ts_enabled Undocumented

Create a time skipper.

Parameters
client:temporalio.client.ClientClient to wrap. A cloned client is created; the original is untouched.
config:TimeSkippingConfigDefault config stamped on every workflow started via client.

Undocumented

async def fast_forward(self, handle: temporalio.client.WorkflowHandle[Any, Any], duration: timedelta | float | None = None, /) -> bool: (source)

Issue a fast-forward on a workflow and wait for it to complete.

Sends an UpdateWorkflowExecutionOptions with the new TimeSkippingConfig. For a bounded duration, long-polls PollWorkflowExecutionTimeSkipping for completion, which follows the workflow across multiple runs.

Parameters
handle:temporalio.client.WorkflowHandle[Any, Any]Target workflow execution.
duration:timedelta | float | NoneOne-shot advance by this amount (timedelta or seconds as a float). If None, enable unbounded skipping and wait for the workflow to terminate.
Returns
For a bounded durationTrue if the fast-forward completes, False if the workflow chain terminates first. Raises RuntimeError if the fast-forward id is overridden by a later fast-forward. For duration=None: always False (there is no fast-forward completion to observe; the call waits until the workflow's terminal event).
async def fast_forward_schedule(self, handle: temporalio.client.ScheduleHandle, duration: timedelta | float, /, *, timeout: timedelta | float | None = SCHEDULE_FAST_FORWARD_POLL_TIMEOUT) -> bool: (source)

Advance a schedule's virtual clock and wait for the fast-forward.

Parameters
handle:temporalio.client.ScheduleHandleTarget schedule.
duration:timedelta | floatAdvance by this amount (timedelta, or seconds as a float). Must be positive: a schedule has no terminal state to skip to, so the server rejects unbounded time skipping on one.
timeout:timedelta | float | NoneHow long to wait for the fast-forward, as passed to poll_schedule_fast_forward. None waits forever.
Returns
boolTrue once the fast-forward reaches its target, and False if it stopped first — time skipping switched off, or the session's skip budget spent.
Raises
ValueErrorIf duration is not positive.
RuntimeErrorIf a later fast-forward replaced this one, which means this one can never complete.
TimeoutErrorIf timeout elapses first. The message says what the schedule was last seen doing.
async def get_current_time(self, handle: temporalio.client.WorkflowHandle[Any, Any]) -> datetime: (source)

Get a workflow's current virtual time.

Reads TimeSkippingInfo.current_time via get_time_skipping_info. If time skipping has never been enabled on the workflow, falls back to wall-clock time (the two coincide when no skipping has ever happened).

async def get_schedule_current_time(self, handle: temporalio.client.ScheduleHandle) -> datetime: (source)

Get a schedule's current virtual time.

Returns
datetimeThe schedule's virtual clock, falling back to wall-clock time when it has never had time skipping enabled.
async def get_schedule_time_skipping_info(self, handle: temporalio.client.ScheduleHandle) -> TimeSkippingInfo | None: (source)

Fetch a schedule's TimeSkippingInfo via DescribeSchedule.

Returns
TimeSkippingInfo | NoneThe schedule's time-skipping state, or None if time skipping has never been enabled on it.

Fetch a workflow's TimeSkippingInfo via DescribeWorkflowExecution.

Returns None if time skipping has never been enabled on the workflow.

async def poll_schedule_fast_forward(self, handle: temporalio.client.ScheduleHandle, fast_forward_id: str, /, *, timeout: timedelta | float | None = SCHEDULE_FAST_FORWARD_POLL_TIMEOUT) -> ScheduleFastForwardPollResult: (source)

Wait for a fast-forward on a schedule to finish.

This is a client-side poll.

A poll on a fast-forward that stops without completing returns a result with ScheduleFastForwardPollResult.failed_reason set, not as an exception.

The loop ignores the schedule's state until it has gotten a server response containing the fast_forward_id that it's waiting for.

Parameters
handle:temporalio.client.ScheduleHandleTarget schedule.
fast_forward_id:strThe FastForwardConfig.id to wait for.
timeout:timedelta | float | NoneHow long to wait. None waits forever.
Returns
ScheduleFastForwardPollResultThe outcome of the wait.
Raises
ValueErrorIf fast_forward_id is empty.
TimeoutErrorIf timeout elapses first. The message says what the schedule was last seen doing, since a schedule's clock only advances while it is idle.
async def set_schedule_time_skipping_config(self, handle: temporalio.client.ScheduleHandle, config: TimeSkippingConfig | None, /): (source)

Replace a schedule's time-skipping configuration.

Parameters
handle:temporalio.client.ScheduleHandleTarget schedule.
config:TimeSkippingConfig | NoneConfiguration to apply. None clears it; the server reads an absent config as "leave it alone", so this sends an explicitly disabled one instead.
def with_time_skipping_disabled(self) -> Iterator[None]: (source)

Suspend time-skipping config stamping on newly-started workflows within the block.

Workflows started via client inside the block do not get their time_skipping_config set; existing workflows are unaffected.

Client that stamps time-skipping config on every started workflow.

Configuration applied to future start_workflow calls.

def _schedule_fast_forward_timeout_message(handle: temporalio.client.ScheduleHandle, fast_forward_id: str, *, observed_own_write: bool, paused: bool, actions: int, reported_id: str) -> str: (source)

Undocumented

async def _poll_fast_forward_completion(self, handle: temporalio.client.WorkflowHandle[Any, Any], fast_forward_id: str) -> bool: (source)

Long-poll for a bounded fast-forward to complete.

Passes run_id="" so the server resolves to the current run in the chain (retry / CAN / cron) and follows the FF across the chain boundary. Retries on server-side long-poll timeout until a terminal poll result arrives.

Replace the stored time-skipping config for a running workflow.

The server accepts the whole TimeSkippingConfig field only, so callers must send a complete config. Public callers should use fast_forward.

async def _wait_for_unbounded_fast_forward_completion(self, handle: temporalio.client.WorkflowHandle[Any, Any]) -> bool: (source)

Enable unbounded time skipping and wait for the workflow to terminate.

There is no fast-forward id to poll on, so we watch history events for a terminal event on the current run. Always returns False — unbounded skipping has no completion event of its own; the wait ends on the workflow's terminal event.

Undocumented

Undocumented

_ts_enabled = (source)

Undocumented