python - 使用 node-celery(MeteorJS) 和 ampq 后端时,Celery 不返回结果

标签 python node.js meteor celery amqp

我刚刚开始使用 Celery,其中 Celery 工作线程是用 Python 编写的,任务是使用 node-celery 从 Node/Meteor 发送的。

为什么client.call()没有返回结果? Python工作控制台显示任务已发送并成功处理。但是 readypending 事件似乎都没有触发!

使用 Celery 3.1.7、RabbitMQ 3.2.2、node-celery 0.1.1、Meteor 0.7.0.1

Node

var celery = Meteor.require('node-celery'),
    client = celery.createClient({
        CELERY_BROKER_URL: 'amqp://guest:guest@localhost:5672//',
        CELERY_RESULT_BACKEND: 'amqp://',
        CELERY_TASK_SERIALIZER: 'json',
        CELERY_RESULT_SERIALIZER: 'json'
    });

client.on('error', function(err) {
    console.log(err);
});

client.on('connect', function() {
    console.log('Connected')

    var results = client.call('tasks.echo', ['Hello world'], function(result) {
        console.log('results:' + result);
    });

    results.on('pending', function(result) {
        console.log('pending: ' + result)
    });

    results.on('ready', function(result) {
        console.log(result)
    });
});

输出

Connected

最佳答案

编辑:

你现在可以在atmospheric上找到我的celery package,或者直接使用mrt install celery安装


我经历了设置此过程的痛苦,但已经走出了另一边。

我最终不得不分支 node-celery ( https://github.com/nathan-muir/node-celery ) 和 node-amqp ( https://github.com/nathan-muir/node-amqp ) 来创建可行的版本。

我已将所有这些装进 meteor 包中 - 但我还没有清理所有内容以供一般消费。 (https://github.com/nathan-muir/meteor-celery)。我想用 Fibers/Futures 包装它,而不是保留回调样式(欢迎拉取请求。

该包从Meteor.settings.celery读取,因此创建一个设置文件,例如:

{
  "celery": {
    "CELERY_BROKER_URL": "amqp://guest@localhost:5672//",
    "CELERY_RESULT_BACKEND": "amqp",
    "CELERY_SEND_TASK_SENT_EVENT": true
  }
}

并使用meteor --settings path/to/settings.json

启动meteor

我还运行启用了事件的客户端和工作人员 (celery worker -E --config=xx),因此我可以使用 celery 监控工具(以及我自己的自定义 cloudwatch 统计监控 https://github.com/nathan-muir/celery-cloudwatch )

如果您还有其他问题 - 请随时在评论中提问。

关于python - 使用 node-celery(MeteorJS) 和 ampq 后端时,Celery 不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20983843/

相关文章:

javascript - 返回 map 内的对象时获取“未定义的 "TypeError: Cannot read property ' 切片”

node.js - Sequelize findAll 方法不返回数据库中的条目

mongodb - 无法使用 'meteor mongo' 连接到本地(正在运行的)mongo

javascript - 从 mongo 集合中的数组为 Select2 选项创建标签对象

javascript - Node.js 外部函数调用

meteor 未知包(0.9.0)

python - 如何在 Pyspark 中获取映射值?

python - for x = str(y) in range(0,5) .... 在 python 中?

python - 使用 Miniconda 创建新的 Python 安装

python - 对使用 requests 库的 python 应用程序进行单元测试