diff --git a/dbm-ui/backend/ticket/tasks/ticket_tasks.py b/dbm-ui/backend/ticket/tasks/ticket_tasks.py index 9025ffaf21..efbad10197 100644 --- a/dbm-ui/backend/ticket/tasks/ticket_tasks.py +++ b/dbm-ui/backend/ticket/tasks/ticket_tasks.py @@ -81,13 +81,6 @@ def retry_exclusive_inner_flow(cls) -> None: for flow in to_retry_flows: InnerFlow(flow_obj=flow).retry() - @classmethod - def _create_ticket(cls, ticket_type, creator, bk_biz_id, remark, details) -> None: - """创建一个新单据""" - Ticket.create_ticket( - ticket_type=ticket_type, creator=creator, bk_biz_id=bk_biz_id, remark=remark, details=details - ) - @classmethod def auto_create_data_repair_ticket(cls): """根据例行校验的结果自动创建修复单据""" @@ -230,12 +223,14 @@ def auto_create_data_repair_ticket(cls): ], } ticket_type = getattr(TicketType, f"{db_type.upper()}_DATA_REPAIR") - cls._create_ticket( - ticket_type=ticket_type, - creator=DEFAULT_SYSTEM_USER, - bk_biz_id=biz, - remark=_("集群存在数据不一致,自动创建的数据修复单据"), - details=ticket_details, + _create_ticket.apply_async( + kwargs={ + "ticket_type": ticket_type, + "creator": DEFAULT_SYSTEM_USER, + "bk_biz_id": biz, + "remark": _("集群存在数据不一致,自动创建的数据修复单据"), + "details": ticket_details, + } ) @classmethod @@ -292,6 +287,12 @@ def get_expire_flow_tickets(expire_type): # ----------------------------- 异步执行任务函数 ---------------------------------------- +@shared_task +def _create_ticket(ticket_type, creator, bk_biz_id, remark, details) -> None: + """创建一个新单据""" + Ticket.create_ticket(ticket_type=ticket_type, creator=creator, bk_biz_id=bk_biz_id, remark=remark, details=details) + + @shared_task def _apply_ticket_task(ticket_id: int, func_name: str, params: dict): """执行异步任务函数体"""