scheduler support coming ..... I think you didn't understand how models works / the scheduler works. Sorry for probably being redundant/naive, but just to check.....
in models belong: def myfunction(): ####whatever #### from gluon.scheduler import Scheduler myscheduler = Scheduler(db) This line basically give you access to the scheduler api and the underlying tables. Now, the following line myscheduler.queue_task( function='my_function', task_name = 'my_function', repeats = 0, # unlimited runs period = 300 # every 5 minutes ) that can be shortened as well as myscheduler.queue_task( my_function, repeats = 0, # unlimited runs period = 300 # every 5 minutes ) does an actual insert on the scheduler_task table. That should be used whenever you need to queue a NEW task. For repeating task, executing that line *one time only* it's all it's needed..... So, if that's your only function, you can either use that line in a controller, or just use the appadmin inserting a *single* row on the scheduler_task table. Repeating functions will be repeated with just ONE row in the scheduler task (where the repeats column != 1) and they'll honour period. status, next_run_time, last_run_time, times_run, times_failed will be updated accordingly to executions on that *single* row. NB: If the function returns something (and doesn't raise an exception), every execution will create a row in the *scheduler_run* table. I think that you have myscheduler.queue_task() in your models, and basically myfunction gets queued every time over and over (because models are executed at every request). That's why you have multiple records in the scheduler_task table and observing "strange" behaviours. Please let me know if this explanation made sense and if not, feel free to ask for further details. On Monday, January 21, 2013 2:31:48 PM UTC+1, Stormcrow wrote: > > I have created a *scheduler.py *in /models/ which looks something like > this: > > def my_function(): > ### function body ### > > scheduler = Scheduler(db) > scheduler.queue_task( > function='my_function', > > task_name = 'my_function', > > repeats = 0, # unlimited runs > > period = 300 # every 5 minutes > > ) > > The problem I'm seeing is that multiple tasks are being created in the > database for this one function at totally incorrect *next_run_time* with > respect to *start_time* and *period*. The multiple tasks created in the > db are also not at the correct time interval apart. In addition, changing > the repeat value to something other than zero has not effect, tasks > continue to be created and executed unrelentingly according to what I see > in the database. > > I am very keen to use the Scheduler, it seems like an elegant solution to > what I'm trying to do but with all these tasks sprouting and executing at > (what appears to be) random it is basically broken. Apologies if I > misunderstood the usage of the scheduler, I was proceeding as close as I > could to what I deciphered from the book. > > Thanks in advance for the help! > --