I'm working on a Django project where I'm using Celery for task scheduling. I have a periodic task that should run every minute, but it seems that Celery Beat is not picking up this task. Here's my setup:
tasks.py:
from celery.schedules import crontab
from ..apps.scraper.scrapers.updates import get_updates
from .settings import app
app.conf.beat_schedule = {
"get_updates": {
"task": "..apps.scraper.scrapers.updates.get_updates",
"schedule": crontab(minute="*/1"), # Run every 1 minute
},
}
celery.py:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "manga_project.settings")
app = Celery("manga_project")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()
app.conf.broker_url = "redis://localhost:6379/0"
updates.py:
@app.task
def get_updates():
print("Looking for manga updates...")
mangas = Manga.objects.all()
for manga in mangas:
print("Checking ", manga.title, " ...")
scrape_chapters("str", manga.url)
I expect the get_updates task to run every minute, but it's not happening. When I start Celery Beat, it doesn't seem to pick up this task when I check the debbuger.
I tried restarting celery and adding some error handling, but the tasks just simply doesnt get picked up so I am not sure how to handle this.
Any advice would be appreciated.