Unable to understand how to implement this things

  1. how should i execute three workflows in parallel using python
  2. how should i execute three activities in parallel using python
  3. how should i execute the one activity only if another activity is successfully completed
  4. how should i execute the one workflow only if another workflow is successfully completed

Hello @Ravikumar

  1. how should i execute three workflows in parallel using python

you can use start_workflow to start your workflows async, see this example https://github.com/temporalio/samples-python/blob/2cb0fdde7ede72edf4b40cf8b5440158d9d2234e/hello/hello_query.py#L42

  1. how should i execute three activities in parallel using python
  1. how should i execute the one activity only if another activity is successfully completed

Await for the activity to complete https://github.com/temporalio/samples-python/blob/2cb0fdde7ede72edf4b40cf8b5440158d9d2234e/hello/hello_activity.py#L33C31-L33C47 , then you can call the next one

result = await workflow.execute_activity(
            compose_greeting,
            ComposeGreetingInput("Hello", name),
            start_to_close_timeout=timedelta(seconds=10),
        )
result_2 = await workflow.execute_activity(
            compose_greeting,
            ComposeGreetingInput("Hello", name),
            start_to_close_timeout=timedelta(seconds=10),
        )
  1. how should i execute the one workflow only if another workflow is successfully completed

Same as previous, use await https://github.com/temporalio/samples-python/blob/2cb0fdde7ede72edf4b40cf8b5440158d9d2234e/hello/hello_activity.py#L58

Can you share your use case, for this ^ looks like child workflows can be useful for you.

Antonio

for the first one if i don’t put sleep will it be parallel should i need to put
await asyncio.sleep(3)
is it provides concurrency or parallel execution of activities

start_workflow sends a request to the server, and whether or not the workflow gets executed depends on if you have workers listening to the taskqueue.

So you can have more than one client sending a request to the server or one client sending many requests at the same time. Your workflow execution can take from seconds to days/months… depending on what you need / your implementation.

This is an async operation, the client sends a request to the server, and on the other side, you need to have workers running and listening on the taskqueue the client has started the workflow. Then the server will start delivering workflow tasks (and activity tasks) to the workers, and your workflows will start making progress.

If you have time take a look at this course, it will help you to understand how it works Temporal 101 with Python | Learn Temporal

I have doubt on below code whether it is concurrency execution or parallel execution

and also in this where actually multiple workflows are executing like one is parent workflow and all other child workflows running parallely

handle = await client.start_workflow(
GreetingWorkflow.run,
“World”,
id=“hello-query-workflow-id”,
task_queue=“hello-query-task-queue”,
)

    # Immediately query
    result = await handle.query(GreetingWorkflow.greeting)
    print(f"First greeting result: {result}")

    # Wait a few of seconds then query again. This works even if the
    # workflow has already completed.
    await asyncio.sleep(3)
    result = await handle.query(GreetingWorkflow.greeting)
    print(f"Second greeting result: {result}")