Fix issue where only one NT attached to UJT would be used to send notifications

This commit is contained in:
Jim Ladd
2019-08-20 20:32:06 -07:00
parent 7a6e62c022
commit 487276613f

View File

@@ -484,7 +484,11 @@ class JobNotificationMixin(object):
except AttributeError: except AttributeError:
raise NotImplementedError("build_notification_message() does not exist" % status) raise NotImplementedError("build_notification_message() does not exist" % status)
def send_it(): # Use kwargs to force late-binding
send_notifications.delay([nt.generate_notification(notification_subject, notification_body).id], # https://stackoverflow.com/a/3431699/10669572
job_id=self.id) def send_it(local_nt=nt, local_subject=notification_subject, local_body=notification_body):
connection.on_commit(send_it) 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())