mrbox是真的,您可以重试,直到结果准备好,但在文档中不太清楚,当您重试时必须通过setid和子任务元素,并且为了恢复它必须使用映射函数,下面有一个示例代码来解释我的意思。
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")