Skip to content
Goal: Proficient✓ Sources verified 2026-11-24TemporalDurable ExecutionSignal

Temporal: A Durable Execution Workflow Engine ​

Temporal is the archetypal workflow engine, and understanding it also deepens your understanding of "resuming from checkpoints".

Core concepts ​

ConceptDescription
WorkflowThe orchestration logic (written as ordinary code); must be deterministic
ActivityConcrete work with side effects: calling an LLM, reading/writing the database, calling external APIs. Can fail and be retried
WorkerThe process you deploy that runs Workflow and Activity code
Temporal ServiceStores each Workflow's event history and handles scheduling, timers and retries
Signal / Query / UpdateSend a message to / query the state of / send and wait for a result from a running Workflow
Retry PolicyActivities have a retry policy by default; Workflows are not retried by default

How it works: durable execution and replay ​

  • Temporal records every event during a Workflow's execution (Activity scheduled, completed and its result, Signal received, timer fired…).
  • After a Worker crashes, a new Worker replays the event history to rebuild the Workflow's in-memory state. Activities that already completed are not re-executed; their results are taken straight from the history.
  • So Workflow code must be deterministic: given the same history, replay must make the same decisions. You can't use the current time, random numbers, direct network calls and so on. The Python SDK offers replacement APIs such as workflow.now() and uses a sandbox to detect non-deterministic behavior.

Default retry policy (official docs) ​

ParameterDefault
Initial Interval1 second
Backoff Coefficient2.0
Maximum Interval100× the initial interval (i.e. 100 seconds)
Maximum Attempts0 (unlimited)
Non-Retryable ErrorsNone

So always set timeouts on Activities (e.g. start_to_close_timeout) and declare non-retryable error types, or they will retry forever.

In practice: waiting for human review with a Signal (Python SDK) ​

python
from datetime import timedelta
from temporalio import workflow
from temporalio.common import RetryPolicy

with workflow.unsafe.imports_passed_through():
    from app.activities import parse_doc, extract_fields, deliver

@workflow.defn
class ContractReview:
    def __init__(self):
        self.review: dict | None = None

    @workflow.signal
    def submit_review(self, review: dict):
        self.review = review              # Signals are delivered at least once: handling must be idempotent

    @workflow.run
    async def run(self, doc_id: str) -> dict:
        opts = dict(start_to_close_timeout=timedelta(minutes=2),
                    retry_policy=RetryPolicy(maximum_attempts=5, non_retryable_error_types=["BadInput"]))
        text = await workflow.execute_activity(parse_doc, doc_id, **opts)
        fields = await workflow.execute_activity(extract_fields, text, **opts)
        if fields["confidence"] < 0.8:
            await workflow.wait_condition(lambda: self.review is not None, timeout=timedelta(days=3))
            fields = self.review or fields
        await workflow.execute_activity(deliver, fields, **opts)
        return fields

Once the reviewer submits in the frontend, the backend calls handle.signal(ContractReview.submit_review, data) and the flow continues, even if it waited three days and the Worker restarted in the meantime.

Common pitfalls ​

  1. Calling an LLM / the database directly in a Workflow: breaks determinism. It must go in an Activity.
  2. Activities without timeouts: combined with the unlimited default retries, problems stay hidden indefinitely.
  3. Changing the code of running Workflows: causes replay mismatches. Use the versioning (patching) mechanism.
  4. Event history too large: Workflows that loop for a long time should use Continue-As-New to reset the history.

Common interview questions ​

  1. How do you split Workflows and Activities? Why must Workflows be deterministic?
  2. After a Worker crashes, how does Temporal resume execution? Are completed Activities re-run?
  3. What is the default Activity retry policy? What are the risks?
  4. How does Temporal handle waiting days for a human review? How would a home-grown solution do it?
  5. How does Temporal differ from Celery, Airflow and Dify/n8n?

How it relates to my projects ​

To be verified / may go stale

  • The example is written against the public API of the Temporal Python SDK; for details such as the timeout parameter of wait_condition, follow the current SDK docs.

Sources ​

Vin Amory · AI development × content creation · Technical notes cite official docs in each page’s sources section