Stack
Stack

Reputation: 1129

Celery Beat Task Hangs With Out Any Errors

I have a Django app, and I'm using Celery Beat to run a task periodically. If I call the task when running Celery, it runs without errors:

app/tasks.py

...
@task(name='task1')
def func():
    # Some code

func.run()
...

If I then start Celery celery -A project worker -l info, the task runs without errors. The issue comes when I try to run that same task with Celery Beat, imagine I have this schedule:

app.conf.beat_schedule = {
    'some_task': {
        'task': 'task1',
        'schedule': crontab(minute=30, hour='22')
    }
}

This task should run every day on 22:30, and it does, the task starts but then hangs without logging anything, I cannot figure out the root of the issue, this is not a memory error, I have already checked that, and the task runs fine on my local machine using Celery Beat. I have also tried to use Celery Beat Daemon, but the task keeps hanging whenever it starts. I can't figure out what is happening, any suggestions?

Upvotes: 0

Views: 1077

Answers (1)

2ps
2ps

Reputation: 15946

Use the app.task or shared_task decorator for your task. Without an app instance, celery beat will not be calling the task with the correct task signature for the celery app to recognize. You can find the documentation on how to write a basic task here.

Upvotes: 1

Related Questions