I have a doubt, suppose I have a task I have to run every day, the task take one hour to complete and suppose I scheduled to start at 5am every day. The first time it's run at 5am, the next day it's run at 5am or at 6am? because I put period=86400sec and the prior task take 1 hour to complete.
2011/8/8 Massimo Di Pierro <massimo.dipie...@gmail.com> > ## preambole > > I have been working on porting django-celery to web2py-celery. > http://code.google.com/p/web2py-celery > There are a few issues to resolve and I am working on it. > > Yet I found it to be overkill for most users. It has lots of > dependencies (for example RabbitMQ) and it is not easy to manage. If > you do not need a huge number of worker nodes there may be a better > solution. > > So I added this to trunk: > > gluon/scheduler.py > > This email is a request for comments as I think this should replace te > current cron mechanism. > > ## What is it? > It is a lightweight replacement for celery that uses the database > instead of queues to schedule tasks and uses the default web2py admin > interface to allow you to schedule tasks. It consists of a single file > and has no dependencies. > > ## How does it work? > > For any existing > app > > Create File: app/models/scheduler.py > ====== > from gluon.scheduler import > Scheduler > > def > demo1(*args,**vars): > print 'you passed args=%s and vars=%s' % (args, > vars) > return > 'done!' > > def > demo2(): > > 1/0 > > scheduler = > Scheduler(db,dict(demo1=demo1,demo2=demo2)) > ===================================== > > Create File: app/modules/scheduler.py > ====== > scheduler.worker_loop() > ===================================== > > ## run worker nodes > with: > python web2py.py -S app -M -N -R applications/app/modules/ > scheduler.py > > ## schedule jobs > using > http://127.0.0.1:8000/scheduler/appadmin/insert/db/task_scheduled > > ## monitor scheduled > jobs > > http://127.0.0.1:8000/scheduler/appadmin/select/db?query=db.task_scheduled.id%3E0 > > ## view completed > jobs > http://127.0.0.1:8000/scheduler/appadmin/select/db?query=db.task_run.id%3E0 > > Compared to celery it lacks the ability to bind tasks and workers , > remotely interrupt tasks and set timeout, yet these features can be > added easily and I will so eventually. > > Please let me know what you think. > > Massimo -- http://martin.tecnodoc.com.ar