2013-06-25 19 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