mrbox가 true 인 경우 결과가 준비 될 때까지 다시 시도 할 수 있지만 다시 시도 할 때 재 시도 할 때 setid 및 하위 타스크 요소를 전달해야하며 복구하려면지도를 사용해야합니다. 함수 아래에는 샘플 코드가 나와 의미를 설명합니다.
http://docs.celeryproject.org/en/latest/userguide/canvas.html#the-primitives에서 : 당신이 원하는 효과를 달성하기 위해 소위 코드를 사용할 수 있습니다 (3.0 이상) 셀러리의 최신 버전에서
def run(self, setid=None, subtasks=None, **kwargs):
if not setid or not subtasks:
#Is the first time that I launch this task, I'm going to launch the subtasks
…
tasks = []
for slice in slices:
tasks.append(uploadTrackSlice.subtask((slice,folder_name)))
job = TaskSet(tasks=tasks)
task_set_result = job.apply_async()
setid = task_set_result.taskset_id
subtasks = [result.task_id for result in task_set_result.subtasks]
self.retry(exc=Exception("Result not ready"), args=[setid,subtasks])
#Is a retry than we just have to check the results
tasks_result = TaskSetResult(setid, map(AsyncResult,subtasks))
if not tasks_result.ready():
self.retry(exc=Exception("Result not ready"), args=[setid,subtasks])
else:
if tasks_result.successful():
return tasks_result.join()
else:
raise Exception("Some of the tasks was failing")