def send_failure_alert(job_name, message, log_exc_info=False, extra_recipients=None):
"""Sends an alert email for a failed job."""
subject = '%s failed in %s' % (job_name, app_identity.get_application_id())
# This sender needs to be authorized per-environment in Email Authorized Senders,
# see https://cloud.google.com/appengine/docs/standard/python/mail/.
sender = config.getSetting(config.INTERNAL_STATUS_MAIL_SENDER)
to_list = config.getSettingList(config.INTERNAL_STATUS_MAIL_RECIPIENTS)
if extra_recipients is not None:
to_list += extra_recipients
logging.error(
'%s: %s (email will be sent from %r to %r)',
subject, message, sender, to_list, exc_info=log_exc_info)
mail.send_mail(sender, to_list, subject, message)
评论列表
文章目录