V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Zioyi
V2EX  ›  问与答

Celery 小白遇坑请教:

  •  
  •   Zioyi · 2017 年 8 月 15 日 · 3230 次点击
    这是一个创建于 3076 天前的主题,其中的信息可能已经有所发展或是发生改变。

    初学,按 blog 写最简单的代码:tasks.py

    from celery import Celery
    app = Celery('tasks', broker='redis://127.0.0.1:6379', backend='redis://127.0.0.1:6379/0')
    @app.task
    def add(x, y):
        return x + y
    

    启动 celery,一切正常 在同 task.py 目录下进入 python 终端

    >>> from tasks import add
    >>> result = add.delay(1,2)
    >>> result.ready()
    

    总是返回 False(试过 n 遍),当在启动 celery 端已显示成功,请问这是为什么? (celery==3.1.8 redis==3.2)

    3 条回复    2017-08-15 20:25:15 +08:00
    MarcoQin
        1
    MarcoQin  
       2017 年 8 月 15 日   ❤️ 1
    刚查了下官方文档,这样写

    AsyncResult.ready()[source]
    Return True if the task has executed.

    If the task is still running, pending, or is waiting for retry then False is returned.
    Zioyi
        2
    Zioyi  
    OP
       2017 年 8 月 15 日
    问题解决,celery -A tasks worker --loglevel=info --pool=solo (添加参数 --pool=solo )
    https://cn.v2ex.com/t/177589
    eloah
        3
    eloah  
       2017 年 8 月 15 日
    4 已经不支持 windows 了......
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2897 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 08:52 · PVG 16:52 · LAX 00:52 · JFK 03:52
    ♥ Do have faith in what you're doing.