Skip to content

taipy.enterprise.scheduler.scheduler.Scheduler

Taipy Scheduler.

A scheduler for periodic methods that lets you run Taipy functions (or any other Python callable) periodically at pre-determined intervals using a simple, human-friendly syntax.

Features:

  • A simple to use API for scheduling methods.
  • Run pending methods on the background thread.
  • Allow to schedule methods by seconds, minutes, hours, days, weeks, months, or even years.
  • Allow to schedule methods to run at a specific time on a specific date.
  • Allow to stop the schedule until a certain time.

Usage:

import taipy as tp
from taipy import Config, Scheduler

# Configure your Taipy application
...
my_scenario_config = Config.configure_scenario("my_scenario", [task_config])

# Schedule creating a scenario every 10 minutes
Scheduler.every(10).minutes.do(tp.create_scenario, my_scenario_config)

# Schedule creating and submiting a scenario every day at 10:30
Scheduler.every().day.at("10:30").do_create_and_submit_scenario(my_scenario_config)

Scheduler.start()

# Do other stuff...

Scheduler.stop()

cancel_scheduled_method(scheduled_method) classmethod

Cancel a scheduled method.

Parameters:

Name Type Description Default
scheduled_method ScheduledMethod

The scheduled method to be unscheduled.

required

clear(tag=None) classmethod

Gets scheduled methods marked with the given tag, or all methods if tag is omitted.

Parameters:

Name Type Description Default
tag Optional[Hashable]

An identifier used to identify a subset of scheduled methods to retrieve.

None

every(interval=1) classmethod

Schedule a new periodic method.

Parameters:

Name Type Description Default
interval int

A quantity of a certain time unit. Defaults to 1.

1

get_scheduled_methods(tag=None) classmethod

Gets scheduled methods marked with the given tag, or all methods if tag is omitted.

Parameters:

Name Type Description Default
tag Optional[Hashable]

An identifier used to identify a subset of methods to retrieve.

None

next_run(tag=None) classmethod

Datetime when the next method should run.

Parameters:

Name Type Description Default
tag Optional[Hashable]

Filter the next run for the given tag parameter.

None

start(interval=60) classmethod

Start the scheduler in a new thread. Pending scheduled methods are executed at each elapsed time interval.

Parameters:

Name Type Description Default
interval float

Time to wait between each check, in seconds. Defaults to 60.

60
Note

It is intended behavior that run_continuously() does not run missed methods. For example, if you've registered a method that should run every minute and you set a continuous run interval of one hour then your method won't be run 60 time at each interval but only once.

stop() classmethod

Stop the scheduler.