您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

芹菜错误:result.get超时

芹菜错误:result.get超时

最终与该项目布局一起工作

proj/celery_proj/__init__.py
                /celery.py
                /tasks.py
    /test.py

哪里

芹菜

from __future__ import absolute_import

from celery import Celery

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

# Optional configuration, see the application user guide.
app.conf.update(
    CELERY_TASK_RESULT_EXPIRES=3600,
)

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

task.py

from __future__ import absolute_import

from celery_proj.celery import app


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


@app.task
def mul(x, y):
    return x * y


@app.task
def xsum(numbers):
    return sum(numbers)

test.py

__author__ = 'mehdi'
path = '/home/mehdi/PycharmProjects'
import sys
sys.path.append(path)
from celery_proj.tasks import add

r = add.delay(4,4)
print(r.status)
print(r.result)

并通过以下方式启动工作人员:

cd proj
celery -A celery_proj worker -l info

然后运行test.py:

python test.py
其他 2022/1/1 18:43:16 有499人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶