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:
fast_forward: advance a running workflow's virtual clock and wait for the fast-forward to complete.get_time_skipping_info: the server's view of a workflow's time skipping.get_current_time: a workflow's virtual clock.with_time_skipping_disabled: stop stamping newly started workflows for the duration of a block.
Schedules:
fast_forward_schedule: advance a schedule's virtual clock and wait for the fast-forward.poll_schedule_fast_forward: wait for a fast-forward issued elsewhere, bounded by a deadline.set_schedule_time_skipping_config: set or clear a schedule's configuration.get_schedule_time_skipping_info: the server's view of a schedule's time skipping.get_schedule_current_time: a schedule's virtual clock.
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 |
Undocumented |
| Async Method | fast |
Issue a fast-forward on a workflow and wait for it to complete. |
| Async Method | fast |
Advance a schedule's virtual clock and wait for the fast-forward. |
| Async Method | get |
Get a workflow's current virtual time. |
| Async Method | get |
Get a schedule's current virtual time. |
| Async Method | get |
Fetch a schedule's TimeSkippingInfo via DescribeSchedule. |
| Async Method | get |
Fetch a workflow's TimeSkippingInfo via DescribeWorkflowExecution. |
| Async Method | poll |
Wait for a fast-forward on a schedule to finish. |
| Async Method | set |
Replace a schedule's time-skipping configuration. |
| Method | with |
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 |
Undocumented |
| Async Method | _poll |
Long-poll for a bounded fast-forward to complete. |
| Async Method | _update |
Replace the stored time-skipping config for a running workflow. |
| Async Method | _wait |
Enable unbounded time skipping and wait for the workflow to terminate. |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _config |
Undocumented |
| Instance Variable | _ts |
Undocumented |
temporalio.client.Client, *, config: TimeSkippingConfig = TimeSkippingConfig()):
(source)
¶
Create a time skipper.
| Parameters | |
client:temporalio.client.Client | Client to wrap. A cloned client is created; the original is untouched. |
config:TimeSkippingConfig | Default config stamped on every workflow started via
client. |
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[ | Target workflow execution. |
duration:timedelta | float | None | One-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 duration | True 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). |
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.ScheduleHandle | Target schedule. |
duration:timedelta | float | Advance 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 | None | How long to wait for the fast-forward, as passed to
poll_schedule_fast_forward. None waits forever. |
| Returns | |
bool | True 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 | |
ValueError | If duration is not positive. |
RuntimeError | If a later fast-forward replaced this one, which means this one can never complete. |
TimeoutError | If timeout elapses first. The message says what the schedule was last seen doing. |
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).
temporalio.client.ScheduleHandle) -> datetime:
(source)
¶
Get a schedule's current virtual time.
| Returns | |
datetime | The schedule's virtual clock, falling back to wall-clock time when it has never had time skipping enabled. |
temporalio.client.ScheduleHandle) -> TimeSkippingInfo | None:
(source)
¶
Fetch a schedule's TimeSkippingInfo via DescribeSchedule.
| Returns | |
TimeSkippingInfo | None | The schedule's time-skipping state, or None if time skipping has never been enabled on it. |
temporalio.client.WorkflowHandle[ Any, Any]) -> temporalio.api.common.v1.TimeSkippingInfo | None:
(source)
¶
Fetch a workflow's TimeSkippingInfo via DescribeWorkflowExecution.
Returns None if time skipping has never been enabled on the
workflow.
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.ScheduleHandle | Target schedule. |
faststr | The FastForwardConfig.id to wait for. |
timeout:timedelta | float | None | How long to wait. None waits forever. |
| Returns | |
ScheduleFastForwardPollResult | The outcome of the wait. |
| Raises | |
ValueError | If fast_forward_id is empty. |
TimeoutError | If timeout elapses first. The message says what the schedule was last seen doing, since a schedule's clock only advances while it is idle. |
temporalio.client.ScheduleHandle, config: TimeSkippingConfig | None, /):
(source)
¶
Replace a schedule's time-skipping configuration.
| Parameters | |
handle:temporalio.client.ScheduleHandle | Target schedule. |
config:TimeSkippingConfig | None | Configuration to apply. None clears it; the server reads
an absent config as "leave it alone", so this sends an explicitly
disabled one instead. |
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.
temporalio.client.ScheduleHandle, fast_forward_id: str, *, observed_own_write: bool, paused: bool, actions: int, reported_id: str) -> str:
(source)
¶
Undocumented
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.
temporalio.client.WorkflowHandle[ Any, Any], config: TimeSkippingConfig) -> temporalio.api.workflowservice.v1.UpdateWorkflowExecutionOptionsResponse:
(source)
¶
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.
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.