雷迪斯不工作。 __init__() 得到了意外的关键字参数“用户名”;
我正在尝试运行 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚通过安装 Redis 包解决了这个问题。
I just solved the problem by installing a Redis bundle.
您的问题很可能是由于连接到 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)
对于将来可能遇到此问题的人:
尝试
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.