@celery.task(base=RequestContextTask, name='import.event', bind=True, throws=(BaseError,))
def import_event_task(self, file, source_type, creator_id):
 task_id = self.request.id.__str__()
 try:
  result = import_event_task_base(self, file, source_type, creator_id)
  update_import_job(task_id, result['id'], 'SUCCESS')
 except BaseError as e:
  print(traceback.format_exc())
  update_import_job(task_id, e.message, (e.status if hasattr(e, 'status') else 'failure'))
  result = {'__error': True, 'result': e.to_dict()}
 except Exception as e:
  print(traceback.format_exc())
  update_import_job(task_id, e.message, (e.status if hasattr(e, 'status') else 'failure'))
  result = {'__error': True, 'result': ServerError().to_dict()}
 send_import_mail(task_id, result)
 return result

@ celery . task ( base = RequestContextTask , name = 'import.event' , bind = True , throws = ( BaseError , ) ) def import_event_task ( self , file , source_type , creator_id ) : task_id = self . request . id . __str__ ( ) try : result = import_event_task_base ( self , file , source_type , creator_id ) update_import_job ( task_id , result [ 'id' ] , 'SUCCESS' ) except BaseError as e : print ( traceback . format_exc ( ) ) update_import_job ( task_id , e . message , ( e . status if hasattr ( e , 'status' ) else 'failure' ) ) result = { '__error' : True , 'result' : e . to_dict ( ) } except Exception as e : print ( traceback . format_exc ( ) ) update_import_job ( task_id , e . message , ( e . status if hasattr ( e , 'status' ) else 'failure' ) ) result = { '__error' : True , 'result' : ServerError ( ) . to_dict ( ) } send_import_mail ( task_id , result ) return result
import event task .