2013-06-25 18 views
5

如果一个任务失败,整个链断裂,Celery链的重点是什么?如果其中一项任务失败,将导致芹菜链中断

我有这样的芹菜链:

res = chain(workme.s (y=1111), workme2.s(2222), workme3.s(3333),)() 

我做workme2失败,这样的重试次数:

@celery.task(default_retry_delay=5, max_retries = 10, queue="sure") 
def workme2(x,y): 
    # try:  
    try: 
     print str(y) 
     sleep(2) 
     print str(x) 
     ## adding any condition that makes the task fail 
     if x!=None: 
      raise Exception('Aproblem from your workme task') 
     print 'This is my username: ' + str(x['user']) + \ 
       ' And Password: ' + str(x['pas'])   
     return "22xx" 
    except Exception, exc: 
     workme2.retry(args=[x,y], exc=exc,) 
+0

http://stackoverflow.com/questions/11508112/retrying-celery-failed-tasks-that-are-part-of-a-chain –

+0

@BernhardVallant,嗨,我在几天前下载了最新版本,这是否意味着这个补丁不包括在内? – securecurve

+0

如果它比3.0.4更新,我想它应该包括在内... –

回答

4

是穴。

形成一个链意味着你的子任务有一些串行依赖:每一个只有在前一个已经执行时才有意义。 没有这个,你只需使用排队或使用一个组而不是一个链。

因此,如果一个子任务失败(并且在尝试所有重试后仍然失败),则链失败。

我欣然承认,the documentation(如芹菜3.1.18的)是远离明确的在这方面,但顾名思义这个语义: “A链是取决于其最薄弱的环节。”

+0

好点:) ..我同意你的观点,在文档中有一些模糊的观点 – securecurve