这是我用来开始芹菜的代码:
from celery import Celery
from foo.lib.config import app
from foo.mods.bar.tract import Tesser
from foo.mods.baz.commons import clean_data, quotify
celery_app = Celery(app.name, broker=app.config["CELERY_BROKER_URL"])
celery_app.conf.update(app.config)
celery_app.autodiscover_tasks()
@celery_app.task
def tract_task(content):
return Tesser.tesseract(content)
@celery_app.task
def clean_data_task(content):
return clean_data(content)
@celery_app.task
def quotify_task(content):
return quotify(content)
我使用以下命令启动工作程序:
celery worker -A celery_tasks.celery_app -l=info
这曾经可以完美地工作,但是当我将celery升级到4.2.0时,出现以下错误:
Traceback (most recent call last):
File "/home/minister/.local/bin/celery", line 11, in <module>
sys.exit(main())
File "/home/minister/.local/lib/python3.5/site-packages/celery/__main__.py", line 16, in main
_main()
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/celery.py", line 322, in main
cmd.execute_from_commandline(argv)
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/celery.py", line 496, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/base.py", line 275, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/celery.py", line 488, in handle_argv
return self.execute(command, argv)
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/celery.py", line 420, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/worker.py", line 223, in run_from_argv
return self(*args, **options)
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/base.py", line 238, in __call__
ret = self.run(*args, **kwargs)
File "/home/minister/.local/lib/python3.5/site-packages/celery/bin/worker.py", line 257, in run
**kwargs)
File "/home/minister/.local/lib/python3.5/site-packages/celery/worker/worker.py", line 96, in __init__
self.app.loader.init_worker()
File "/home/minister/.local/lib/python3.5/site-packages/celery/loaders/base.py", line 114, in init_worker
self.import_default_modules()
File "/home/minister/.local/lib/python3.5/site-packages/celery/loaders/base.py", line 108, in import_default_modules
raise response
File "/home/minister/.local/lib/python3.5/site-packages/celery/utils/dispatch/signal.py", line 288, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/minister/.local/lib/python3.5/site-packages/vine/promises.py", line 143, in __call__
return self.throw()
File "/home/minister/.local/lib/python3.5/site-packages/vine/promises.py", line 140, in __call__
retval = fun(*final_args, **final_kwargs)
File "/home/minister/.local/lib/python3.5/site-packages/celery/app/base.py", line 673, in _autodiscover_tasks
return self._autodiscover_tasks_from_fixups(related_name)
File "/home/minister/.local/lib/python3.5/site-packages/celery/app/base.py", line 683, in _autodiscover_tasks_from_fixups
pkg for fixup in self._fixups
File "/home/minister/.local/lib/python3.5/site-packages/celery/app/base.py", line 684, in <listcomp>
for pkg in fixup.autodiscover_tasks()
AttributeError: 'NoneType' object has no attribute 'autodiscover_tasks'
最新版本中做了哪些更改,我需要对代码进行哪些更改?这可以是一个错误吗?