猿问

如何解决芹菜文件中关键字参数namespace='"CELERY"错误的芹菜工人配置

我有一个名为 ShippingApp 的项目名称,我按照步骤设置了 celery worker。我将 celery 3.1.26.post2 与 python3.7 一起使用,当我想启动 Celery Worker 时,出现以下错误:


E:\ShippingApp>celery -A ShippingApp worker -l info

Traceback (most recent call last):

  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main

    "__main__", mod_spec)

  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code

    exec(code, run_globals)

  File "C:\Program Files\Python37\Scripts\celery.exe\__main__.py", line 9, in <module>

  File "c:\program files\python37\lib\site-packages\celery\__main__.py", line 30, in main

    main()

  File "c:\program files\python37\lib\site-packages\celery\bin\celery.py", line 81, in main

    cmd.execute_from_commandline(argv)

  File "c:\program files\python37\lib\site-packages\celery\bin\celery.py", line 793, in execute_from_commandline

    super(CeleryCommand, self).execute_from_commandline(argv)))

  File "c:\program files\python37\lib\site-packages\celery\bin\base.py", line 309, in execute_from_commandline

    argv = self.setup_app_from_commandline(argv)

  File "c:\program files\python37\lib\site-packages\celery\bin\base.py", line 469, in setup_app_from_commandline

    self.app = self.find_app(app)

  File "c:\program files\python37\lib\site-packages\celery\bin\base.py", line 489, in find_app

    return find_app(app, symbol_by_name=self.symbol_by_name)

  File "c:\program files\python37\lib\site-packages\celery\app\utils.py", line 235, in find_app

    sym = symbol_by_name(app, imp=imp)


在我使用 celery 4.2.1 但它与 Windows 10 不兼容之前,我卸载了它并安装了 3.1.26.post2 版本。请协助。


心有法竹
浏览 208回答 1
1回答

梵蒂冈之花

大写命名空间意味着所有 celery 配置必须用大写而不是小写指定,并以CELERY_ 开头,例如,task_always_eager设置变为CELERY_TASK_ALWAYS_EAGER,而broker_url变为CELERY_BROKER_URL等等。这个配置是celery4.0以后引入的。因此,对于版本 <4,您不需要namespace排队:app.config_from_object('django.conf:settings', namespace='CELERY')将以上内容替换为:app.config_from_object('django.conf:settings')注意:如果您使用 celery 3.1,请检查您的 Django 版本。它应该 <1.8
随时随地看视频慕课网APP

相关分类

Python
我要回答