Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions backend/app/task/celery_task/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio

from typing import Any

from celery import Task
Expand Down Expand Up @@ -34,7 +36,7 @@ async def on_success(self, retval: Any, task_id: str, args, kwargs) -> None:
"""
await task_notification(msg=f'任务 {task_id} 执行成功')

async def on_failure(self, exc: Exception, task_id: str, args, kwargs, einfo) -> None:
def on_failure(self, exc: Exception, task_id: str, args, kwargs, einfo) -> None:
"""
任务失败后执行钩子

Expand All @@ -43,4 +45,5 @@ async def on_failure(self, exc: Exception, task_id: str, args, kwargs, einfo) ->
:param einfo: 异常信息
:return:
"""
await task_notification(msg=f'任务 {task_id} 执行失败')
loop = asyncio.get_event_loop()
loop.create_task(task_notification(msg=f'任务 {task_id} 执行失败'))