diff --git a/sql/utils/tasks.py b/sql/utils/tasks.py index 15de20f7fb..e866cf9a55 100644 --- a/sql/utils/tasks.py +++ b/sql/utils/tasks.py @@ -3,6 +3,7 @@ from celery import signature from celery.result import AsyncResult from celery.exceptions import SoftTimeLimitExceeded +from django.http import JsonResponse import logging import pytz @@ -56,11 +57,12 @@ def del_schedule(name): except Exception as e: print(f"终止任务时发生错误:{str(e)}") - def task_info(name): """获取定时任务详情""" - try: - periodic_task = PeriodicTask.objects.get(name=name) - return periodic_task - except PeriodicTask.DoesNotExist: - return None \ No newline at end of file + task_result = AsyncResult(name) + response = { + 'task_id': name, + 'status': task_result.state, + 'result': task_result.result + } + return JsonResponse(response)