0

This might have nothing to do with celery but here is my problem:

I have an app structured like this:

/app
   /__init__.py
   /api_1.0/foo.py
/proj
   /__init__.py
   /celery.py
   /tasks.py

So in celery.py I create a celery app:

flask = create_app(os.getenv('FLASKCONFIG') or None)
celery = Celery(__name__,
    broker=flask.config['CELERY_BROKER_URL'],
    include=['proj.tasks'])

celery.conf.update(flask.config)

and in tasks.py there are lists of celery tasks. One of them is list_users

In foo.py I try to use the task:

from proj import tasks

but this is causing an importation problem when I do:

celery -A proj worker --logleve=info

error message:

from proj.celery import celery
    ImportError: cannot import name celery

Strange enough, if I remove the creation of the flask app and simply create a celery app, the problem goes away. it looks like a circular import problem. How to avoid this?

lang2
  • 11,433
  • 18
  • 83
  • 133

0 Answers0