Starting Celery: AttributeError: 'module' object has no attribute 'celery'

后端 未结 6 1354
南旧
南旧 2021-02-04 02:33

I try to start a Celery worker server from a command line:

celery -A tasks worker --loglevel=info

The code in tasks.py:

import          


        
6条回答
  •  一向
    一向 (楼主)
    2021-02-04 02:57

    My problem was that I put the celery variable inside a main function:

    if __name__ == '__main__':  # Remove this row
        app = Flask(__name__)
        celery = make_celery(app) 
    

    when it should be put outside.

提交回复
热议问题