Skip to content

You can download the code of this step here or all the steps here.

Step 7: Execution modes

Taipy has different ways to execute the code. Changing the execution mode can be useful for running multiple tasks in parallel. - standalone mode: asynchronous. Jobs can be run in parallel depending on the graph of execution if max_nb_of_workers > 1. - development mode: synchronous.

In this step, we define a new configuration and functions to showcase the two execution modes.

# Normal function used by Taipy
def double(nb):
    return nb * 2

def add(nb):
    print("Wait 10 seconds in add function")
    return nb + 10

This line of code will change the execution mode (the default execution mode is development). Changing it to standalone will make Taipy Core asynchronous. Here a maximum of two tasks will be able to run concurrently.

Config.configure_job_executions(mode="standalone", max_nb_of_workers=2)
if __name__=="__main__":
    scenario_1 = tp.create_scenario(scenario_cfg)
    scenario_2 = tp.create_scenario(scenario_cfg)



Jobs from the two submissions are being executed simultaneously. If max_nb_of_workers was greater, we could run multiple scenarios at the same time and multiple tasks of a scenario at the same time.

Some options for the submit function exist:

  • wait: if wait is True, the submit is synchronous and will wait for the end of all the jobs (if timeout is not defined).

  • timeout: if wait is True, Taipy will wait for the end of the submission up to a certain amount of time.

if __name__=="__main__":
    scenario_1 = tp.create_scenario(scenario_cfg)
    scenario_1.submit(wait=True, timeout=5)