django-celery PeriodicTask and eta field -
i have django project in combination celery , need able schedule tasks dynamically, @ point in future, recurrence or not. need ability delete/edit scheduled tasks
so achieve @ beginning started using django-celery databasescheduler store periodictasks (with expiration) database described more or less here
in way if close app , start again schedules still there
my problem though still remains since cannot utilize eta , schedule task @ point in future. possible somehow dynamically schedule task eta?
a second question of mine whether can schedule once off task, schedule run e.g. @ 2015-05-15 15:50:00 (that why i'm trying use eta)
finally, scheduling thousants of notifications, celery beat capable handle number of scheduled tasks? of them once-off while others being periodic? or have go more advanced solution such apscheduler
thank you
i've faced same problem yesterday. ugly temporary solution is:
# tasks.py     djcelery.models import periodictask, intervalschedule datetime import timedelta, datetime django.utils.timezone import  ...  @app.task def schedule_periodic_task(task='app.tasks.task', task_args=[], task_kwargs={},                            interval=(1, 'minute'), expires=now()+timedelta(days=365*100)):     periodictask.objects.filter(name=task+str(task_args)+str(task_kwargs)).delete()     task = periodictask.objects.create(         name=task+str(task_args)+str(task_kwargs), task=task,         args=str(task_args),         kwargs=str(task_kwargs),         interval=intervalschedule.objects.get_or_create(             every=interval[0],             period=interval[1])[0],         expires=expires,     )     task.save()   so, if want schedule periodic task eta, shoud
# anywhere.py     schedule_periodic_task.apply_async(     kwargs={'task': 'grabber.tasks.grab_events',             'task_args': [instance.xbet_id], 'task_kwargs': {},             'interval': (10, 'seconds'),             'expires': instance.start + timedelta(hours=3)},     eta=instance.start, )   schedule task eta, creates periodic task. ugly:
- deal raw.task.name
 - strange period (n, 'interval')
 
please, let me know, if designed pretty solution.
Comments
Post a Comment