我是任务队列的新手。当我打开外壳程序并从外壳程序中的功能执行功能add.delay(3,4)
来执行任务时。我得到:<AsyncResult: 30db3528-5b0f-4e74-bf47-51956a1f83e9>
。我如何从该函数中获取结果,以及如何安排将结果在5秒后执行?
#celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
app = Celery('RedisQueue')
app.autodiscover_tasks()
`@app.task
def add(a, b):
return a + b`
#__ init __。py
from __future__ import absolute_import, unicode_literals
__all__ = ['celery_app']
#settings.py
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'