使用nodeclery(MeteorJS)和ampq后端时,Celery不返回任何结果

2024-06-07 23:19:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚开始使用celeri,其中celeri worker是用Python编写的,任务是使用node-celery从node/Meteor发送的。在

为什么没有从client.call()返回result?pythonworker控制台显示任务已发送并成功处理。但是ready和{}似乎没有触发!在

使用芹菜3.1.7,RabbitMQ 3.2.2,节点芹菜0.1.1,流星0.7.0.1

节点

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)
    });
});

输出

^{pr2}$

Tags: clientlognodeonfunctionresultcallresults
2条回答

编辑:

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


我经历了设置这个的痛苦,但是我已经走出了另一边。在

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

我把这一切都装进了流星的包装里,但我还没有把所有的东西都清理干净,供一般人食用。(https://github.com/nathan-muir/meteor-celery)。我想用Fibers/Futures包装它,而不是留下回调样式(pull requests欢迎使用)。在

包从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开始流星

我还运行启用了事件的客户机和工作人员(celery worker -E config=xx),这样我就可以使用celery监视工具(以及我自己定制的cloudwatchstats监视器https://github.com/nathan-muir/celery-cloudwatch

如果你还有什么问题,可以在评论中自由提问。在

我没有用流星,但我有一个类似的问题,node-celery。希望这将有助于其他人,将绊倒在这个问题。在

在我的例子中,我可以通过在芹菜配置.py文件

CELERY_TASK_SERIALIZER = 'json'

CELERY_ACCEPT_CONTENT = ['json']

CELERY_RESULT_BACKEND = 'amqp'

CELERY_RESULT_SERIALIZER = 'json'

我的nodejs节点芹菜调用如下:

^{pr2}$

相关问题 更多 >

    热门问题