Please help me to get out of this problem I am getting this when I am running
celery -A app.celery worker --loglevel=info
Error:
Unable to load celery application.
The module app.celery was not found.
My code is--
# Celery Configuration
from celery import Celery
from app import app
print("App Name=",app.import_name)
celery=Celery(app.name,broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
@celery.task
def download_content():
return "hello"
directory structure-- newYoutube/app/auth/routes.py and this function is present inside routes.py auth is blueprint.
When invoking celery via
celery -A app.celery ...
celery will look for the name celery
in the app
namespace, expecting it to hold an instance of Celery
. If you put that elsewhere (say, in app.auth.routes
), then celery won't find it.
I have a working example you can crib from at https://github.com/davewsmith/flask-celery-starter
Or, refer to chapter 22 of the Flask Mega Tutorial, which uses rx
instead of celery
, but the general approach to structuring the code is similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With