From d1c293940a74b28715959756313034b03ff2f437 Mon Sep 17 00:00:00 2001 From: Aaron3S Date: Thu, 18 Apr 2024 14:08:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20celery=20task=20not?= =?UTF-8?q?=20found=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/signal_handlers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/ops/signal_handlers.py b/apps/ops/signal_handlers.py index 2d56de828..19665c53f 100644 --- a/apps/ops/signal_handlers.py +++ b/apps/ops/signal_handlers.py @@ -129,8 +129,7 @@ def task_sent_handler(headers=None, body=None, **kwargs): logger.error("Not found task id or name: {}".format(info)) return - args = info.get('argsrepr', '()') - kwargs = info.get('kwargsrepr', '{}') + args, kwargs, _ = body try: args = list(ast.literal_eval(args)) kwargs = ast.literal_eval(kwargs) @@ -143,13 +142,16 @@ def task_sent_handler(headers=None, body=None, **kwargs): 'name': task, 'state': 'PENDING', 'is_finished': False, - 'args': ["too long params" if item is Ellipsis else item for item in args], + 'args': args, 'kwargs': kwargs } request = get_current_request() if request and request.user.is_authenticated: data['creator'] = request.user - CeleryTaskExecution.objects.create(**data) + try: + CeleryTaskExecution.objects.create(**data) + except Exception as e: + logger.error(e) CeleryTask.objects.filter(name=task).update(date_last_publish=timezone.now())