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)