From 487276613fea12585d433f8f036b2cbfcd23b2b2 Mon Sep 17 00:00:00 2001 From: Jim Ladd Date: Tue, 20 Aug 2019 20:32:06 -0700 Subject: [PATCH] Fix issue where only one NT attached to UJT would be used to send notifications --- awx/main/models/notifications.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index b3cf738adc..25ad018eb7 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -484,7 +484,11 @@ class JobNotificationMixin(object): except AttributeError: raise NotImplementedError("build_notification_message() does not exist" % status) - def send_it(): - send_notifications.delay([nt.generate_notification(notification_subject, notification_body).id], - job_id=self.id) - connection.on_commit(send_it) + # Use kwargs to force late-binding + # https://stackoverflow.com/a/3431699/10669572 + def send_it(local_nt=nt, local_subject=notification_subject, local_body=notification_body): + def _func(): + send_notifications.delay([local_nt.generate_notification(local_subject, local_body).id], + job_id=self.id) + return _func + connection.on_commit(send_it())