Skip to content

Replay-Safe Values

Internal implementation module: async_durable_execution._operation.replay_safe.

Use random(), now(), timestamp(), and uuid() when workflow code needs common nondeterministic values. Each helper creates a named durable step and reuses the checkpointed value during replay.

from async_durable_execution import now, random as durable_random, timestamp, uuid


request_id = await uuid(name="request_id")
created_at = await now(name="created_at")
created_at_seconds = await timestamp(name="created_at_seconds")
sample = await durable_random(name="sample")

Replay-safe helpers for common non-deterministic values.

Functions:

random

random(*, name: str | None = None) -> Task[float]

Return a checkpointed random.random() value.

now

now(*, name: str | None = None) -> Task[datetime]

Return a checkpointed timezone-aware UTC datetime.

timestamp

timestamp(*, name: str | None = None) -> Task[float]

Return a checkpointed Unix timestamp in seconds.

uuid

uuid(*, name: str | None = None) -> Task[UUID]

Return a checkpointed UUID4 value.