def queue_subtasks_for_query(entry, action_name, create_subtask_fcn, item_querysets, item_fields, items_per_task, total_num_items):
 task_id = entry.task_id
 total_num_subtasks = _get_number_of_subtasks(total_num_items, items_per_task)
 subtask_id_list = [str(uuid4()) for _ in range(total_num_subtasks)]
 TASK_LOG.info('Task %s: updating InstructorTask %s with subtask info for %s subtasks to process %s items.', task_id, entry.id, total_num_subtasks, total_num_items)
 with outer_atomic():
  progress = initialize_subtask_info(entry, action_name, total_num_items, subtask_id_list)
 item_list_generator = _generate_items_for_subtask(item_querysets, item_fields, total_num_items, items_per_task, total_num_subtasks, entry.course_id)
 TASK_LOG.info('Task %s: creating %s subtasks to process %s items.', task_id, total_num_subtasks, total_num_items)
 num_subtasks = 0
 for item_list in item_list_generator:
  subtask_id = subtask_id_list[num_subtasks]
  num_subtasks += 1
  subtask_status = SubtaskStatus.create(subtask_id)
  new_subtask = create_subtask_fcn(item_list, subtask_status)
  new_subtask.apply_async()
 return progress

def queue_subtasks_for_query ( entry , action_name , create_subtask_fcn , item_querysets , item_fields , items_per_task , total_num_items ) : task_id = entry . task_id total_num_subtasks = _get_number_of_subtasks ( total_num_items , items_per_task ) subtask_id_list = [ str ( uuid4 ( ) ) for _ in range ( total_num_subtasks ) ] TASK_LOG . info ( 'Task %s: updating InstructorTask %s with subtask info for %s subtasks to process %s items.' , task_id , entry . id , total_num_subtasks , total_num_items ) with outer_atomic ( ) : progress = initialize_subtask_info ( entry , action_name , total_num_items , subtask_id_list ) item_list_generator = _generate_items_for_subtask ( item_querysets , item_fields , total_num_items , items_per_task , total_num_subtasks , entry . course_id ) TASK_LOG . info ( 'Task %s: creating %s subtasks to process %s items.' , task_id , total_num_subtasks , total_num_items ) num_subtasks = 0 for item_list in item_list_generator : subtask_id = subtask_id_list [ num_subtasks ] num_subtasks += 1 subtask_status = SubtaskStatus . create ( subtask_id ) new_subtask = create_subtask_fcn ( item_list , subtask_status ) new_subtask . apply_async ( ) return progress
generates and queues subtasks to each execute a chunk of "items" generated by a queryset .