0% found this document useful (0 votes)
36 views3 pages

Continue-As-New - Python SDK - Temporal Platform Documentation

The document provides guidance on using the Continue-As-New feature in the Temporal Python SDK, which allows a Workflow Execution to close and create a new one in a single operation to manage large Event Histories. It explains how to implement this by calling the continue_as_new() function within a Workflow and notes that it should be used only after completing all handlers. Additionally, it emphasizes that Continue-As-New cannot be used within Update handlers.

Uploaded by

pine147miren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Continue-As-New - Python SDK - Temporal Platform Documentation

The document provides guidance on using the Continue-As-New feature in the Temporal Python SDK, which allows a Workflow Execution to close and create a new one in a single operation to manage large Event Histories. It explains how to implement this by calling the continue_as_new() function within a Workflow and notes that it should be used only after completing all handlers. Additionally, it emphasizes that Continue-As-New cannot be used within Update handlers.

Uploaded by

pine147miren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Continue-As-New - Python SDK | Temporal Platform Documentation 10.04.

2025, 17:10

Develop

Python SDK Continue-As-New

Continue-As-New -
Python SDK
How to Continue-As-New using
the Temporal Python SDK.

Continue-As-New enables a
Workflow Execution to close
successfully and create a new
Workflow Execution in a single
atomic operation if the number of
Events in the Event History is
becoming too large. The Workflow
Execution spawned from the use of
Continue-As-New has the same
Workflow Id, a new Run Id, and a
fresh Event History and is passed all
the appropriate parameters.

To Continue-As-New in Python, call


the continue_as_new() function
from inside your Workflow, which will
stop the Workflow immediately and
Continue-As-New.

View the in the context of the


source rest of the application
code code.

# ... Ask AI
@workflow.defn

https://docs.temporal.io/develop/python/continue-as-new Page 1 of 3
Continue-As-New - Python SDK | Temporal Platform Documentation 10.04.2025, 17:10

class LoopingWorkflow:
@workflow.run
async def run(self, iteration
int) -> None:
if iteration == 5:
return
await asyncio.sleep(

workflow.continue_as_new(iteration
+ 1)

USING CONTINUE-AS-NEW
AND UPDATES
Temporal does not support
Continue-as-New
functionality within Update
handlers.
Complete all handlers
before using Continue-as-
New.
Use Continue-as-New from
your main Workflow
Definition method, just as
you would complete or fail
a Workflow Execution.

Tags: Workflows

continue-as-new Python SDK

Temporal SDKs

https://docs.temporal.io/develop/python/continue-as-new Page 2 of 3
Continue-As-New - Python SDK | Temporal Platform Documentation 10.04.2025, 17:10

Help us make
Temporal
better.
Contribute to
our
documentation.

https://docs.temporal.io/develop/python/continue-as-new Page 3 of 3

You might also like