芹菜结果显示已禁用

时间:2018-06-01 18:47:30

标签: python django rabbitmq celery

我是芹菜新手。在我的django应用程序中安装celery后,我在Django shell中运行以下命令:

import os
from celery import Celery
from django.apps import apps

app = Celery('')
app.config_from_object('ns.settings')
@app.task                            
def add(x, y):   
   return x + y

我可以得到结果:

In [5]: add.delay(4,4)
Out[5]: <AsyncResult: f632d828-07d5-4f6b-b538-2aee6617b7ab>

我认为异步任务已成功构建,但我无法得到任何结果:

In [4]: result = add.delay(4,4)
Start from server, version: 0.9, properties: {'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'product': 'RabbitMQ', 'copyright': 'Copyright (C) 2007-2018 Pivotal Software, Inc.', 'capabilities': {'exchange_exchange_bindings': True, 'connection.blocked': True, 'authentication_failure_close': True, 'direct_reply_to': True, 'basic.nack': True, 'per_consumer_qos': True, 'consumer_priorities': True, 'consumer_cancel_notify': True, 'publisher_confirms': True}, 'cluster_name': 'rabbit@rabbit', 'platform': 'Erlang/OTP 19.2.1', 'version': '3.6.15'}, mechanisms: ['AMQPLAIN', 'PLAIN'], locales: [u'en_US']
[13:49:41] amqp _on_start():340 Start from server, version: 0.9, properties: {'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'product': 'RabbitMQ', 'copyright': 'Copyright (C) 2007-2018 Pivotal Software, Inc.', 'capabilities': {'exchange_exchange_bindings': True, 'connection.blocked': True, 'authentication_failure_close': True, 'direct_reply_to': True, 'basic.nack': True, 'per_consumer_qos': True, 'consumer_priorities': True, 'consumer_cancel_notify': True, 'publisher_confirms': True}, 'cluster_name': 'rabbit@rabbit', 'platform': 'Erlang/OTP 19.2.1', 'version': '3.6.15'}, mechanisms: ['AMQPLAIN', 'PLAIN'], locales: [u'en_US']
using channel_id: 1
[13:49:41] amqp __init__():108  using channel_id: 1
Channel open
[13:49:41] amqp _on_open_ok():445   Channel open

In [7]: result.ready()
Out[7]: False

In [8]: result.status
Out[8]: u'PENDING'

当芹菜首次开始时,我看到以下信息:

tasks_1      |  -------------- celery@31a95a569866 v4.1.0 (latentcall)
tasks_1      | ---- **** ----- 
tasks_1      | --- * ***  * -- Linux-4.9.87-linuxkit-aufs-x86_64-with-debian-8.10 2018-06-01 13:14:32
tasks_1      | -- * - **** --- 
tasks_1      | - ** ---------- [config]
tasks_1      | - ** ---------- .> app:         __main__:0x7efc50ed6810
tasks_1      | - ** ---------- .> transport:   amqp://guest:**@localhost:5672//
tasks_1      | - ** ---------- .> results:     disabled://
tasks_1      | - *** --- * --- .> concurrency: 2 (prefork)
tasks_1      | -- ******* ---- .> task events: ON
tasks_1      | --- ***** ----- 
tasks_1      |  -------------- [queues]
tasks_1      |                 .> default          exchange=default(direct) key=default
tasks_1      |                 
tasks_1      | 

结果已被停用。我认为这是因为我的后端设置符合this

result_backend = 'cache'
#result_backend = 'cache+memcached://memcached:11211/'
cache_backend = 'memory'
task_create_missing_queues = True
task_track_started = True
task_default_queue = 'celery'
task_always_eager = False
task_eager_propagates = True
task_ignore_result = True
task_store_errors_even_if_ignored = True

我尝试了此设置或仅尝试了注释行。我遇到了同样的残疾问题。

你知道如何解决这个问题吗?如果您想通过某些命令查看更多结果。我会告诉你。

0 个答案:

没有答案