On Nov 5, 2010, at 12:46 AM, Rami Sayar wrote:
> Hi,
>
> Thank you very much for the timely and detailed response. I just wanted to clarify something, does a periodic task currently start instantly or the next time the scheduler loops? I want it to start instantly.
>
> Also, if I wanted to create a flag for this, maybe call it eager_execution. Where would I need to modify the celery source (besides the PeriodicTask Model), approximately? If this is interesting to everyone, I can submit a patch.
>
>
You mean like, periodic tasks that has not been executed before should be executed immediately?
If you install the release21-maint branch this should be possible by using:
from djcelery imoprt schedulers
class ImmediateFirstEntry(schedulers.ModelEntry):
def is_due(self):
if self.last_run_at is None:
return True, 0
return super(ImmediateFirstEntry, self).is_due()
def _default_now(self):
return None
class MySched(schedulers.DatabaseScheduler):
Entry = ImmediateFirstEntry
Then using this scheduler with celerybeat:
$ python manage.py celerybeat -S myapp.schedulers.Mysched --loglevel=debug
You need to install release21-maint of django-celery for the _default_now method:
pip install -U http://github.com/ask/django-celery/tarball/release21-maint#egg=celery
--
{Ask Solem,
Developer ~ Webteam,
Opera Software,
+47 98435213 | twitter.com/asksol }.