Nis*_*kar 0 django rabbitmq celery
我正在尝试在 django 视图中异步运行任务。为此,我使用 celery 和rabbitmq。通过遵循小规模上下文指南,我在模块(servicenow.py)中将任务定义为 -
app = Celery('servicenow',broker='amqp://username:password@localhost:15672')
.
.
@app.task
def get_ITARAS_dump(self):
.
.
self.update_state(state='PROGRESS',meta={'current':i,'total':len(taskList)})
Run Code Online (Sandbox Code Playgroud)
我的rabbitmq服务器在brew服务中运行
之后我尝试启动一个工作实例,
celery -A servicenow worker -l info然后我的错误消息为 -
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/celery", line 11, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/__main__.py", line 30, in main
main()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/celery.py", line 81, in main
cmd.execute_from_commandline(argv)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/celery.py", line 793, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/base.py", line 311, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/celery.py", line 785, in handle_argv
return self.execute(command, argv)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/celery.py", line 717, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/worker.py", line 179, in run_from_argv
return self(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/base.py", line 274, in __call__
ret = self.run(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/bin/worker.py", line 194, in run
pool_cls = (concurrency.get_implementation(pool_cls) or
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/concurrency/__init__.py", line 29, in get_implementation
return symbol_by_name(cls, ALIASES)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/concurrency/prefork.py", line 20, in <module>
from celery.concurrency.base import BasePool
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/concurrency/base.py", line 21, in <module>
from celery.utils import timer2
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/celery/utils/timer2.py", line 19
from kombu.async.timer import Entry, Timer as Schedule, to_timestamp, logger
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我认为这是一个版本问题,但根据要求我认为我已经正确了
django-celery==3.2.2
- celery [required: >=3.1.15,<4.0, installed: 3.1.26.post2]
- billiard [required: >=3.3.0.23,<3.4, installed: 3.3.0.23]
- kombu [required: >=3.0.37,<3.1, installed: 3.0.37]
- amqp [required: >=1.4.9,<2.0, installed: 1.4.9]
- anyjson [required: >=0.3.3, installed: 0.3.3]
- pytz [required: >dev, installed: 2018.7]
- django [required: >=1.8, installed: 2.1.3]
- pytz [required: Any, installed: 2018.7]
Run Code Online (Sandbox Code Playgroud)
请帮忙,我无法确定我是否缺少配置步骤或版本问题。另外,如果有人可以验证这些步骤是否正确,以便使用 celery 在模块级别执行异步任务。谢谢!
嗯,这是Celery的一个已知问题。Celery 尚不支持 python 3.7。昆布也一样。因此将 python 降级到 3.6 或以前的版本。您可以在https://github.com/celery/celery/issues/4500检查该问题的状态
| 归档时间: |
|
| 查看次数: |
4457 次 |
| 最近记录: |