17👍
✅
How about using celeryd_after_setup
or celeryd_init
signal?
Follwing example code from the documentation:
from celery.signals import celeryd_init
@celeryd_init.connect(sender='worker12@example.com')
def configure_worker12(conf=None, **kwargs):
...
-1👍
I found the way to do this. It has one negative side – impossible to specify current year and task will run after year again. But usually server restarts more often, then this period.
from celery.task import PeriodicTask
class InitialTasksStarter(PeriodicTask):
starttime = datetime.now() + timedelta(minutes=1)
run_every = crontab(month_of_year=starttime.month, day_of_month=starttime.day, hour=starttime.hour, minute=starttime.minute)
def run(self, **kwargs):
....
return True
- Django Tutorial: name 'HttpResponse' is not defined
- Creating an entire web application using django admin
- Django reverse to contains/icontains
Source:stackexchange.com