Zioyi
V2EX  ›  问与答

Celery 小白遇坑请教:

  •  
  •   Zioyi · Aug 15, 2017 · 3479 views
    This topic created in 3240 days ago, the information mentioned may be changed or developed.

    初学,按 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 replies    2017-08-15 20:25:15 +08:00
    MarcoQin
        1
    MarcoQin  
       Aug 15, 2017   ❤️ 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
       Aug 15, 2017
    问题解决,celery -A tasks worker --loglevel=info --pool=solo (添加参数 --pool=solo )
    https://cn.v2ex.com/t/177589
    eloah
        3
    eloah  
       Aug 15, 2017
    4 已经不支持 windows 了......
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4156 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:13 · PVG 12:13 · LAX 21:13 · JFK 00:13
    ♥ Do have faith in what you're doing.