def get(self, pk): """ Gets a given task's result :param pk: Primary key """ result = celery.AsyncResult(pk) return Response(result.get(), status=status.HTTP_200_OK)
def get(self, pk): """ Gets a given task's result :param pk: Task identifier :type pk: str :return: Task result :rtype: dict """ result = celery.AsyncResult(pk) return result.get()
def retrieve(self, pk): """ Load information about a given task """ result = celery.AsyncResult(pk) if result.successful(): result_data = result.result else: result_data = str(result.result) if result.result is not None else None data = {'id' : result.id, 'status' : result.status, 'successful': result.successful(), 'failed' : result.failed(), 'ready' : result.ready(), 'result' : result_data} return Response(data, status=status.HTTP_200_OK)
def retrieve(self, pk): """ Load information about a given task :param pk: Task identifier :type pk: str :return: Task metadata (status, result, ...) :rtype: dict """ result = celery.AsyncResult(pk) result_status = result.status result_successful = result.successful() if result_successful is True: result_data = result.result else: result_data = str( result.result) if result.result is not None else None return { 'id': result.id, 'status': result_status, 'successful': result_successful, 'failed': result.failed(), 'ready': result.ready(), 'result': result_data }