Skip to content

Commit

Permalink
增加日志
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Aug 3, 2018
1 parent 89d935a commit 3575dc5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sql/sendmail.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import traceback
from multiprocessing import Process
import email
from email import encoders
Expand All @@ -10,6 +9,9 @@
import smtplib

from django.conf import settings
import logging

logger = logging.getLogger('default')


class MailSender(object):
Expand Down Expand Up @@ -87,5 +89,8 @@ def _send(self, strTitle, strContent, listToAddr, **kwargs):

# 调用方应该调用此方法,采用子进程方式异步阻塞地发送邮件,避免邮件服务挂掉影响archer主服务
def sendEmail(self, strTitle, strContent, listToAddr, **kwargs):
p = Process(target=self._send, args=(strTitle, strContent, listToAddr), kwargs=kwargs)
p.start()
try:
p = Process(target=self._send, args=(strTitle, strContent, listToAddr), kwargs=kwargs)
p.start()
except Exception:
logger.error(traceback.format_exc())

0 comments on commit 3575dc5

Please sign in to comment.