wiki:DeveloperGuidelines/Scheduler

Version 1 (modified by James O'Neill, 12 years ago) ( diff )

Simple page on how to use the scheduler

The scheduler is used for asynchronous tasks (not from a user request to the web server). It is used for daily instance maintenance and for processing and sending messages.

The Eden scheduler is a wrapper to the web2py scheduler.

New Task

To create a new function in /models/tasks.py for your new task, and point to it by setting a value in the tasks dictionary, e.g.,

def my_task(*args, **kwargs):
        return result

tasks["my_task"] = my_task

Task schedules are configured by using s3task.schedule_task() in /models/zzz_1st_run.py.

s3task.schedule_task(
        "my_task",
        args=[
                "foo",
        ],
        vars={
                "bar": "cha",
        },
        period=300, # every 5 minutes
        repeat=0 # run forever
)

Note that tasks are run without credentials.

Note: See TracWiki for help on using the wiki.