I have a celery schedule which is configured like this:
CELERYBEAT_SCHEDULE = {
"runs-every-30-seconds": {
"task": "tasks.refresh",
"schedule": timedelta(hours=1)
},
}
After testing I find that this schedule is started after 1 hour, but I want to run this schedule instantly and again after 1 hour.
If you mean at startup, do it in AppConfig.ready() (new in django 1.7):
# my_app/__init__.py:
class MyAppConfig(AppConfig):
def ready(self):
tasks.refresh.delay()
Also see: https://docs.djangoproject.com/en/1.7/ref/applications/#module-django.apps
If you're only doing this for the tests, I'd rather call/delay the tasks directly than testing the celery scheduler itself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.