简体   繁体   English

Django Celery Worker无法接收任务

[英]Django Celery Worker Not reciving the Tasks

Whenever I am running the celery worker I am getting the warning 每当我经营芹菜工人时,我都会得到警告

./manage.py celery worker -l info --concurrency=8

在此处输入图片说明

and if I am ignored this warning then my celery worker not receiving the celery beat tasks 如果我忽略了此警告,则我的芹菜工人不接受芹菜节拍任务

After googled I have also changed the worker name, but this time I am not receiving the warning but celery worker still not receiving the celery beat scheduled tasks 谷歌搜索后,我还更改了工人名称,但是这次我没有收到警告,但是芹菜工人仍然没有收到芹菜节拍计划任务

I have checked the celery beat logs, and celery beat scheduling the task on time. 我已经检查了芹菜节拍日志,并且芹菜节拍按时安排了任务。

I have also checked the celery flower and its showing two workers and the first worker is receiving the tasks and not executing it, how to send all task the second worker? 我还检查了芹菜花,它显示了两个工作人员,而第一个工作人员正在接收任务而不执行任务,如何将所有任务发送给第二个工作人员? or how can i disable the first kombu worker, what is djagno-celery setting that i am missing? 或者如何禁用第一个海带工人,我缺少的djagno-celery设置是什么?

My django settings.py 我的Django settings.py

RABBITMQ_USERNAME = "guest"
RABBITMQ_PASSWORD = "guest"
BROKER_URL = 'amqp://%s:%s@localhost:5672//' % (RABBITMQ_USERNAME, 
RABBITMQ_PASSWORD)
CELERY_DEFAULT_QUEUE = 'default'
CELERY_DEFAULT_EXCHANGE = 'default'
CELERY_DEFAULT_ROUTING_KEY = 'default'
CELERY_IGNORE_RESULT = True
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
celery_enable_utc=True
import djcelery
djcelery.setup_loader()

You only enabled the worker. 您仅启用了工作进程。 For a task to be executed, you must call the task with the help of the your_task.delay () function. 对于要执行的任务,必须在your_task.delay ()函数的帮助下调用该任务。 For example, open another terminal, enter your project, and run the python manage.py shell command. 例如,打开另一个终端,输入您的项目,然后运行python manage.py shell命令。 When entering the shell of your project Django, import your task and run the command your_task.delay () In the following link, there is an example of celery code with rabbitmq broker, I advise you to study it: https://github.com/celery/celery/tree/master/examples/django 当进入您的项目Django的外壳时,导入您的任务并运行命令your_task.delay ()在以下链接中,有一个Rabbitmq代理的celery代码示例,建议您研究一下: https://github.com。 com / celery / celery / tree / master / examples / django

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM