From 52d8d851feb938a033ebe153fcd3b1982421b0b7 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 26 Apr 2018 09:36:43 -0400 Subject: [PATCH] avoid unrelated errors saving notification --- awx/main/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 470da6f1f2..7e4afac382 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -270,6 +270,7 @@ def send_notifications(notification_list, job_id=None): job_actual.notifications.add(*notifications) for notification in notifications: + update_fields = ['status', 'notifications_sent'] try: sent = notification.notification_template.send(notification.subject, notification.body) notification.status = "successful" @@ -278,8 +279,9 @@ def send_notifications(notification_list, job_id=None): logger.error(six.text_type("Send Notification Failed {}").format(e)) notification.status = "failed" notification.error = smart_str(e) + update_fields.append('error') finally: - notification.save() + notification.save(update_fields=update_fields) @shared_task(bind=True, queue=settings.CELERY_DEFAULT_QUEUE)