雷迪斯不工作。 __init__() 得到了意外的关键字参数“用户名”;

发布于 2025-01-16 23:51:02 字数 1107 浏览 5 评论 0原文

我正在尝试运行 celery -A 项目工作人员 -l 信息。但每次它都会返回一个错误,例如 init 遇到意外错误。请帮助。 提前致谢。

我的设置文件:

CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Africa/Nairobi'

celery 文件:

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# setting the Django settings module.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')

# Looks up for task modules in Django applications and loads them
app.autodiscover_tasks()


@app.task(bind=True)
def debug_task():
    print('Request')

init 文件

from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

i am trying to run the celery -A project worker -l info. But each time it returns an error like init got unexpected error. Kindly Help.
Thanks in advance.

my settings file:

CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Africa/Nairobi'

celery file:

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# setting the Django settings module.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')

# Looks up for task modules in Django applications and loads them
app.autodiscover_tasks()


@app.task(bind=True)
def debug_task():
    print('Request')

init file

from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

打小就很酷 2025-01-23 23:51:02

我刚刚通过安装 Redis 包解决了这个问题。

pip install "celery[redis]"

I just solved the problem by installing a Redis bundle.

pip install "celery[redis]"
寂寞美少年 2025-01-23 23:51:02

您的问题很可能是由于连接到 Redis 时 Kombu 的回归造成的。前进的方法是按照此处的说明进行操作: https://github.com/celery/kombu /issues/1419 或将 Kombu 固定到较低版本。 (我将 Kombu 固定到 5.0.2)

Your issue are most likely due to a regression in Kombu when connecting to redis. The way forward is either to follow the instructions here: https://github.com/celery/kombu/issues/1419 or to pin Kombu to a lower version. (I pinned Kombu to 5.0.2)

壹場煙雨 2025-01-23 23:51:02

对于将来可能遇到此问题的人:

尝试 pip list 并检查安装的 redis 版本。我在 3.2.1 中看到过这个问题。如果是这种情况,请尝试版本 2.5.3,它应该可以工作。

For someone who might have this issue in the future:

try pip list and check what version of redis is installed. I have seen this issue with 3.2.1. If that's the case try version 2.5.3 and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文