def get_task_data(task_id):
 result = AsyncResult(task_id)
 (state, info) = (result.state, result.info)
 if (state == 'PENDING'):
  raise TaskNotFound(task_id)
 if ('task_name' not in info):
  raise TaskNotFound(task_id)
 try:
  task = celery_app.tasks[info['task_name']]
 except KeyError:
  raise TaskNotFound(task_id)
 return (task, state, info)

def get_task_data ( task_id ) : result = AsyncResult ( task_id ) ( state , info ) = ( result . state , result . info ) if ( state == 'PENDING' ) : raise TaskNotFound ( task_id ) if ( 'task_name' not in info ) : raise TaskNotFound ( task_id ) try : task = celery_app . tasks [ info [ 'task_name' ] ] except KeyError : raise TaskNotFound ( task_id ) return ( task , state , info )
will raise tasknotfound if the task is in state pending or the task meta data has no task_name key set .