I'm having problems integrating Celery in my Flask application. This is the repo https://github.com/theobouwman/community-python.
I start my app by running app.py
which imports my app (where blueprints and config are added) and Celery.
In /tasks/add.py
I have a sample task and where I import the Celery
object again for the @celery.task
decorator.
Till that point everything works fine. I can run my Flask application and run the Celery worker.
But when I try to trigger a task from within a controller in a Blueprint like here https://github.com/theobouwman/community-python/blob/master/auth/controllers/RegistrationController.py#L38 it says that it cannot import it, which it a logic reaction.
Traceback (most recent call last):
File "app.py", line 2, in <module>
from flask_app import app
File "/development/projects/python/Community/flask_app.py", line 4, in <module>
from auth.routes import auth
File "/development/projects/python/Community/auth/routes.py", line 3, in <module>
from .controllers import RegistrationController, AuthenticationController, LogoutController
File "/development/projects/python/Community/auth/controllers/RegistrationController.py", line 10, in <module>
from tasks.add import add
File "/development/projects/python/Community/tasks/add.py", line 1, in <module>
from app import celery
File "/development/projects/python/Community/app.py", line 2, in <module>
from flask_app import app
ImportError: cannot import name 'app'
I don't know how to fix this import cycle and that's the reason for this question. I googled for like 3 hours but couldn't find a solution. I hope someone here could help me.
And is there a Flask Slack or Gitter in the air?
Thanks in advance.