Why does Celery work in Python shell, but not in my Django views? (import problem)

后端 未结 3 2110
渐次进展
渐次进展 2020-12-29 08:47

I installed Celery (latest stable version.) I have a directory called /home/myuser/fable/jobs. Inside this directory, I have a file called tasks.py:

         


        
3条回答
  •  情深已故
    2020-12-29 09:08

    See Automatic Naming and Relative Imports, in the docs:

    http://celeryq.org/docs/userguide/tasks.html#automatic-naming-and-relative-imports

    The tasks name is "tasks.Submitter" (as listed in the celeryd output), but you import the task as "fable.jobs.tasks.Submitter"

    I guess the best solution here is if the worker also sees it as "fable.jobs.tasks.Submitter", it makes more sense from an app perspective.

    CELERY_IMPORTS = ("fable.jobs.tasks", )
    

提交回复
热议问题