Python + Celery:链接工作?

Python + Celery:链接工作?,第1张

Python + Celery:链接工作

您可以用芹菜链来做。参见https://celery.readthedocs.org/en/latest/userguide/canvas.html#chains

@task()def add(a, b):    time.sleep(5) # simulate long time processing    return a + b

链接工作

# import chain from celery import chain# the result of the first add job will be # the first argument of the second add jobret = chain(add.s(1, 2), add.s(3)).apply_async()# another way to express a chain using pipesret2 = (add.s(1, 2) | add.s(3)).apply_async()...# check ret status to get resultif ret.status == u'SUCCESS':    print "result:", ret.get()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5645818.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存