From f174b62c7c8e740cb20847c9f5cafa8daaa8aa5f Mon Sep 17 00:00:00 2001 From: yanta Date: Thu, 19 Sep 2024 14:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=81=97=E6=BC=8F=E7=9A=84ta?= =?UTF-8?q?sk=5Fjob?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/archiver.py | 7 ------- sql/sql_workflow.py | 14 ++++++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/sql/archiver.py b/sql/archiver.py index d04ea7f5bf..092ee46785 100644 --- a/sql/archiver.py +++ b/sql/archiver.py @@ -312,13 +312,6 @@ def add_archive_task(archive_ids=None): # 添加task任务 for archive_info in archive_cnf_list: archive_id = archive_info.id - async_task( - "sql.archiver.archive", - archive_id, - group=f'archive-{time.strftime("%Y-%m-%d %H:%M:%S ")}', - timeout=-1, - task_name=f"archive-{archive_id}", - ) archive.apply_async( args=[archive_id], task_id=f"archive-{archive_id}", # Celery 允许你指定自定义的任务ID diff --git a/sql/sql_workflow.py b/sql/sql_workflow.py index f5853437e6..717791111c 100644 --- a/sql/sql_workflow.py +++ b/sql/sql_workflow.py @@ -491,12 +491,14 @@ def cancel(request): else True ) if is_notified: - async_task( - notify_for_audit, - workflow_audit=auditor.audit, - workflow_audit_detail=workflow_audit_detail, - timeout=60, - task_name=f"sqlreview-cancel-{workflow_id}", + # 异步调用 Celery 任务 + notify_for_audit.apply_async( + args=[ + auditor.audit.audit_id, + workflow_audit_detail.audit_detail_id, + ], + time_limit=60, # 设置此次任务的超时时间为60秒 + task_id=f"sqlreview-cancel-{workflow_id}", # 可选,自定义任务ID ) return HttpResponseRedirect(reverse("sql:detail", args=(workflow_id,)))