From 45e1723aa95dbc855112497f794c90fcb5ca2de9 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 16 Aug 2023 18:17:32 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=9C=BA=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=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/terminal/api/applet/host.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/terminal/api/applet/host.py b/apps/terminal/api/applet/host.py index f0dce9785..6b06ee44e 100644 --- a/apps/terminal/api/applet/host.py +++ b/apps/terminal/api/applet/host.py @@ -1,3 +1,4 @@ +from django.db import transaction from rest_framework import status from rest_framework import viewsets from rest_framework.decorators import action @@ -58,7 +59,8 @@ class AppletHostDeploymentViewSet(viewsets.ModelViewSet): def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) - instance = serializer.save() + with transaction.atomic(): + instance = serializer.save() task = run_applet_host_deployment.delay(instance.id) instance.save_task(task.id) return Response({'task': str(task.id)}, status=201)