From 1b221d1cb6dfca114d9245595665f24b4a374c72 Mon Sep 17 00:00:00 2001 From: Aaron3S Date: Thu, 18 Apr 2024 16:41:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20celery=20kwargs=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/ops/signal_handlers.py b/apps/ops/signal_handlers.py index ab60d19cb..6fb2ced2d 100644 --- a/apps/ops/signal_handlers.py +++ b/apps/ops/signal_handlers.py @@ -1,4 +1,5 @@ import ast +import json import time from celery import signals @@ -9,6 +10,7 @@ from django.db.utils import ProgrammingError from django.dispatch import receiver from django.utils import translation, timezone from django.utils.functional import LazyObject +from rest_framework.utils.encoders import JSONEncoder from common.db.utils import close_old_connections, get_logger from common.signals import django_ready @@ -130,10 +132,11 @@ def task_sent_handler(headers=None, body=None, **kwargs): return args, kwargs, __ = body + try: - args = list(ast.literal_eval(args)) - kwargs = ast.literal_eval(kwargs) - except (ValueError, SyntaxError): + args = list(args) + kwargs = json.loads(json.dumps(kwargs, cls=JSONEncoder)) + except Exception as e: args = [] kwargs = {}