mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 06:51:10 +03:00
Merge pull request #2336 from ryanpetrello/fix-notification-race
send test notifications after the transaction closes to avoid a race
This commit is contained in:
commit
7684579464
@ -19,7 +19,7 @@ import six
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import FieldError, ObjectDoesNotExist
|
from django.core.exceptions import FieldError, ObjectDoesNotExist
|
||||||
from django.db.models import Q, Count, F
|
from django.db.models import Q, Count, F
|
||||||
from django.db import IntegrityError, transaction
|
from django.db import IntegrityError, transaction, connection
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils.encoding import smart_text
|
from django.utils.encoding import smart_text
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
@ -4960,7 +4960,7 @@ class NotificationTemplateTest(GenericAPIView):
|
|||||||
if not notification:
|
if not notification:
|
||||||
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
send_notifications.delay([notification.id])
|
connection.on_commit(lambda: send_notifications.delay([notification.id]))
|
||||||
data = OrderedDict()
|
data = OrderedDict()
|
||||||
data['notification'] = notification.id
|
data['notification'] = notification.id
|
||||||
data.update(NotificationSerializer(notification, context=self.get_serializer_context()).to_representation(notification))
|
data.update(NotificationSerializer(notification, context=self.get_serializer_context()).to_representation(notification))
|
||||||
|
Loading…
Reference in New Issue
Block a user