芹菜任务结果无法与rpc保持一致 [英] Celery task results not persisted with rpc

查看:66
本文介绍了芹菜任务结果无法与rpc保持一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过使结果持久化到队列中并使另一个进程可以从队列中选择结果,来将Celery任务结果路由到另一个进程.因此,已将Celery配置为CELERY_RESULT_BACKEND ='rpc',但Python函数返回的值仍未持久存储在队列中.

I have been trying to get Celery task results to be routed to another process by making results persisted to a queue and another process can pick results from queue. So, have configured Celery as CELERY_RESULT_BACKEND = 'rpc', but still Python function returned value is not persisted to queue.

不确定是否需要任何其他配置或代码更改.请帮忙.

Not sure if any other configuration or code change required. Please help.

这是代码示例:

celery.py

celery.py

from __future__ import absolute_import

from celery import Celery

app = Celery('proj',
         broker='amqp://',
         backend='rpc://',
         include=['proj.tasks'])

# Optional configuration, see the application user guide.
app.conf.update(
    CELERY_RESULT_BACKEND = 'rpc',
    CELERY_RESULT_PERSISTENT = True,
    CELERY_TASK_SERIALIZER = 'json',
    CELERY_RESULT_SERIALIZER = 'json'
)

if __name__ == '__main__':
    app.start()

tasks.py

from proj.celery import app

@app.task
def add(x, y):
    return x + y

将芹菜作为

celery worker --app=proj -l info --pool=eventlet -c 4

推荐答案

通过使用Pika(AMQP 0-9-1协议的Python实现- https://pika.readthedocs.org )将结果发布回celeryresults频道

Solved by using Pika (Python implementation of the AMQP 0-9-1 protocol - https://pika.readthedocs.org) to post results back to celeryresults channel

这篇关于芹菜任务结果无法与rpc保持一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆