本文整理汇总了Python中celery.task.sets.TaskSet.completed_count方法的典型用法代码示例。如果您正苦于以下问题:Python TaskSet.completed_count方法的具体用法?Python TaskSet.completed_count怎么用?Python TaskSet.completed_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.task.sets.TaskSet
的用法示例。
在下文中一共展示了TaskSet.completed_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startDownload
# 需要导入模块: from celery.task.sets import TaskSet [as 别名]
# 或者: from celery.task.sets.TaskSet import completed_count [as 别名]
def startDownload(request):
"""
Ajax call to start the download
"""
if request.user.is_authenticated():
if request.method == 'POST':
profile = request.user.profile
if profile.stage > 0:
if profile.stage < 3:
result = TaskSetResult.restore(profile.task_id)
response_data = {
"error": "download already started",
"stage" : profile.stage,
"completed" : result.completed_count(),
"total" : result.total,
}
else:
reponse_data = {
"error": "download already finished",
"stage" : profile.stage,
"state" : "completed",
}
else:
graphapi = facebook.GraphAPI(profile.fblogin.access_token)
me = graphapi.get_object('me')
friends = [(f['id'],f['name']) for f in graphapi.get_connections('me','friends')['data']]
friends.append((me['id'],me['name']))
subtasks = [tasks.dlUser.subtask((profile.id,graphapi,fbid,name)) for (fbid,name) in friends]
result = TaskSet(tasks=subtasks).apply_async()
result.save()
profile.stage = 1
profile.task_id = result.taskset_id
profile.save()
r = tasks.checkTaskSet.delay(result,profile.id)
response_data = {
"stage":1,
"completed": result.completed_count(),
"total": result.total,
}
else:
response_data = {
"error": "must be a post request"
}
else:
response_data = {
"error": "user must be logged in"
}
return HttpResponse(json.dumps(response_data), mimetype="application/json")