1

I am trying to learn how to use celery to later integrate into my flask app. I am just trying to execute the basic example found on the Celery Docs I have created a file called task.py and from within that folder where the file task.py is existing i am running celery -A tasks worker --loglevel=info but it is giving an error. I can't seem to figure out what is wrong.

from celery import Celery

app = Celery('tasks', broker='amqp://localhost')

@app.task
def add(x, y):
    return x + y

error I am seeing

celery -A tasks worker --loglevel=info

ImportError: No module named 'tasks'

1 Answer 1

2

Try executing the command from application folder level. If your tasks.py is inside flask_app/configs/tasks.py, then run the following command from inside flask_app folder.

celery worker --app=configs.tasks:app --loglevel=info

if you want to daemonize celery use following command

celery multi start worker --app=configs.tasks:app --loglevel=info

** multi start will daemonize the celery,

and be sure to activate virtualenv before running the command, if the application is running inside one.

I am successfully running celery in django with django-celery, had faced the same issue.

Sign up to request clarification or add additional context in comments.

1 Comment

celery multi v4.1.0 (latentcall) > Starting nodes... > worker@myhost: OK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.