蟒蛇芹菜不起作用



我是芹菜和蟒蛇的新手,想使用芹菜在应用程序中执行异步任务。当我试图查看它是如何工作的时,演示应用程序本身无法在我的本地设置上运行。我在系统上本地启动了 rabbitmq 服务器,默认配置:用户:来宾,密码:来宾和默认端口 5672。

我从 http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html 中挑选了示例代码

from celery import Celery
app = Celery('tasks', broker='amqp://guest:guest@localhost:5672/hello')
@app.task
def add(x, y):
    return x + y

所有这些都是完成的,并放置在虚拟环境中。然后我在包含 app.py 文件的文件夹位置并使用以下命令:芹菜 -任务工作线程 --loglevel=info 从终端运行芹菜工作线程。执行命令后获得以下输出:

Traceback (most recent call last):
  File "/usr/local/bin/celery", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/celery/__main__.py", line 13, in main
    from celery.bin.celery import main as _main
  File "/Library/Python/2.7/site-packages/celery/bin/__init__.py", line 2, in <module>
    from .base import Option
  File "/Library/Python/2.7/site-packages/celery/bin/base.py", line 17, in <module>
    from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
  File "/Library/Python/2.7/site-packages/celery/local.py", line 509, in __getattr__
    module = __import__(self._object_origins[name], None, None, [name])
  File "/Library/Python/2.7/site-packages/celery/app/__init__.py", line 5, in <module>
    from celery import _state
  File "/Library/Python/2.7/site-packages/celery/_state.py", line 15, in <module>
    from celery.utils.threads import LocalStack
  File "/Library/Python/2.7/site-packages/celery/utils/__init__.py", line 9, in <module>
    from .functional import memoize  # noqa
  File "/Library/Python/2.7/site-packages/celery/utils/functional.py", line 11, in <module>
    from kombu.utils.functional import (
ImportError: cannot import name LRUCache

使用的依赖项:AMQP 2.2.2, 台球 3.5.0.3, 芹菜 4.1.0, 昆布 4.1.0, 蟒蛇 3.6

让我知道错误,是否需要任何其他详细信息

运行芹菜工人的当前命令将是:

celery -A app worker --loglevel=info

前提是您的工作器文件被调用 app.py

试试这个:

app = Celery('tasks', broker='pyamqp://guest@localhost:5672/')

另外(即使我认为这与你的错误无关(你说你使用 python 3.6,但在错误跟踪上它看起来像是 2.7 版。

尝试安装Billiard and Kombu的开发版本:

pip install -e git+https://github.com/celery/billiard.git#egg=billiard
pip install -e git+https://github.com/celery/kombu.git#egg=kombu

相关内容

  • 没有找到相关文章