10

What is the point of Celery chain if the whole chain breaks if one of the tasks fail?!!

I have this Celery chain:

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

And I made workme2 fails with retries like this:

@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,)
4

1 回答 1

19

就是重点。

形成一个链意味着您的子任务具有某种串行依赖性:每个子任务只有在前一个已执行时才有意义。如果没有这个,您将简单地使用队列或使用组而不是链。

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

我欣然承认文档(从 Celery 3.1.18 开始)在这方面远非明确,但其名称暗示了这种语义:“链的强度取决于其最薄弱的环节。”

于 2015-09-11T08:44:39.330 回答