refector: send_mail_task优化
This commit is contained in:
parent
407068670c
commit
f2c02a76d4
|
@ -12,7 +12,7 @@ myLogger = logging.getLogger('log')
|
|||
def send_mail_task(**args):
|
||||
if settings.DEBUG is False:
|
||||
from django.core.mail import send_mail
|
||||
args['subject'] = args.get('subject', '{}:{}_{}_500'.format(settings.SYS_NAME, settings.SYS_VERSION, settings.PROJECT_NAME))
|
||||
args['subject'] = '{}:{}_{}_{}'.format(settings.SYS_NAME, settings.SYS_VERSION, settings.PROJECT_NAME, args.get('subject', '500'))
|
||||
args['from_email'] = args.get('from_email', settings.EMAIL_HOST_USER)
|
||||
args['recipient_list'] = args.get('recipient_list', [settings.EMAIL_HOST_USER])
|
||||
send_mail(**args)
|
||||
|
|
|
@ -48,14 +48,14 @@ def run_task(ticket_id: str, retry_num=1):
|
|||
except Exception:
|
||||
retry_num_new = retry_num - 1
|
||||
if retry_num_new >= 0:
|
||||
time.sleep(5)
|
||||
time.sleep(10)
|
||||
run_task.delay(ticket_id, retry_num_new)
|
||||
return
|
||||
err_detail = traceback.format_exc()
|
||||
myLogger.error('工作流脚本执行失败', exc_info=True)
|
||||
script_result = False
|
||||
script_result_msg = err_detail
|
||||
send_mail_task.delay(subject='ehs_wf_task_error', message=err_detail) # run_task执行失败发送邮件
|
||||
send_mail_task.delay(subject='wf_task_error', message=err_detail) # run_task执行失败发送邮件
|
||||
ticket = Ticket.objects.filter(id=ticket_id).first()
|
||||
if not script_result:
|
||||
ticket.script_run_last_result = False
|
||||
|
|
Loading…
Reference in New Issue