Scheduled Tasks

To create a new experiment-specific background tasks, you can register classmethods or functions on your experiment class using the scheduled_task decorator:

from dallinger import experiment

class MyCustomExperiment(experiment.Experiment):

    @experiment.scheduled_task("interval", minutes=15)
    def my_background_task(cls):

If the clock_on configuration parameter is enabled, then functions registered using this decorator will be run by the clock server on the specified interval. You can configure the frequency of the background task via arguments to the decorator. The arguments should be identical to those of the appscheduler.scheduled_job. method. The first argument is the trigger type, which can be one of “interval”, “cron”, or “date”. See the documentation links above for details on trigger specific arguments. The "date" trigger type can be used without additional arguments to run a task immediately when the clock server starts.