@task()
@timeit
def index_chunk_task(write_index, batch_id, rec_id, chunk):
 (cls_path, id_list) = chunk
 cls = from_class_path(cls_path)
 rec = None
 from kitsune.search.models import Record
 try:
  pin_this_thread()
  rec = Record.objects.get(pk=rec_id)
  rec.start_time = datetime.datetime.now()
  rec.message = (u'Reindexing into %s' % write_index)
  rec.status = Record.STATUS_IN_PROGRESS
  rec.save()
  index_chunk(cls, id_list, reraise=True)
  rec.mark_success()
 except Exception:
  if (rec is not None):
   rec.mark_fail((u'Errored out %s %s' % (sys.exc_type, sys.exc_value)))
  log.exception('Error while indexing a chunk')
  raise IndexingTaskError()
 finally:
  unpin_this_thread()

@ task ( ) @ timeit def index_chunk_task ( write_index , batch_id , rec_id , chunk ) : ( cls_path , id_list ) = chunk cls = from_class_path ( cls_path ) rec = None from kitsune . search . models import Record try : pin_this_thread ( ) rec = Record . objects . get ( pk = rec_id ) rec . start_time = datetime . datetime . now ( ) rec . message = ( u'Reindexing into %s' % write_index ) rec . status = Record . STATUS_IN_PROGRESS rec . save ( ) index_chunk ( cls , id_list , reraise = True ) rec . mark_success ( ) except Exception : if ( rec is not None ) : rec . mark_fail ( ( u'Errored out %s %s' % ( sys . exc_type , sys . exc_value ) ) ) log . exception ( 'Error while indexing a chunk' ) raise IndexingTaskError ( ) finally : unpin_this_thread ( )
index a chunk of things .