Changes between Initial Version and Version 1 of DeveloperGuidelines/Scheduler


Ignore:
Timestamp:
09/11/12 03:58:36 (10 years ago)
Author:
James O'Neill
Comment:

Simple page on how to use the scheduler

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Scheduler

    v1 v1  
     1The 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.
     2
     3The Eden scheduler is a wrapper to the [http://web2py.com/books/default/chapter/29/4#Scheduler-%28experimental%29 web2py scheduler].
     4
     5== New Task ==
     6To 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.,
     7
     8{{{
     9#!python
     10def my_task(*args, **kwargs):
     11        return result
     12
     13tasks["my_task"] = my_task
     14}}}
     15
     16Task schedules are configured by using [http://pub.nursix.org/eden/s3/s3.s3task.S3Task-class.html#schedule_task s3task.schedule_task()] in `/models/zzz_1st_run.py`.
     17
     18{{{
     19#!python
     20s3task.schedule_task(
     21        "my_task",
     22        args=[
     23                "foo",
     24        ],
     25        vars={
     26                "bar": "cha",
     27        },
     28        period=300, # every 5 minutes
     29        repeat=0 # run forever
     30)
     31}}}
     32
     33Note that tasks are run without credentials.