| | 1 | 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. |
| | 2 | |
| | 3 | The Eden scheduler is a wrapper to the [http://web2py.com/books/default/chapter/29/4#Scheduler-%28experimental%29 web2py scheduler]. |
| | 4 | |
| | 5 | == New Task == |
| | 6 | 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., |
| | 7 | |
| | 8 | {{{ |
| | 9 | #!python |
| | 10 | def my_task(*args, **kwargs): |
| | 11 | return result |
| | 12 | |
| | 13 | tasks["my_task"] = my_task |
| | 14 | }}} |
| | 15 | |
| | 16 | Task 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 |
| | 20 | s3task.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 | |
| | 33 | Note that tasks are run without credentials. |