Merge pull request #11305 from jumpserver/pr@dev@perf_task_err

perf: 修复发布机任务执行失败的问题
pull/11307/head
老广 2023-08-16 18:43:02 +08:00 committed by GitHub
commit d5ac8b16f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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)