Skip to main content

How to spawn a Workflow Execution in Python

To start a Workflow Execution in python, use either the start_workflow() or execute_workflow() asynchronous methods in the Client.

The following code example starts a Workflow and returns its handle.

async def main():
client = await Client.connect("127.0.0.1:7233", namespace="your-custom-namespace")

handle = await client.start_workflow(
"your-workflow-name",
"some arg",
id="your-workflow-id",
task_queue="your-task-queue",
)

The following code example starts a Workflow and waits for completion.

async def main():
client = await Client.connect("127.0.0.1:7233", namespace="your-custom-namespace")

handle = await client.execute_workflow(
"your-workflow-name",
"some arg",
id="your-workflow-id",
task_queue="your-task-queue",
)