程序异常时发送邮件提醒,且会自动进行重试
This commit is contained in:
13
main.py
13
main.py
@@ -1,5 +1,7 @@
|
||||
import logging.config
|
||||
import traceback
|
||||
|
||||
from auto_email.error_email import send_an_error_email
|
||||
from config.log import LOGGING_CONFIG
|
||||
from photo_review.photo_review import main
|
||||
|
||||
@@ -8,4 +10,13 @@ if __name__ == '__main__':
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
log = logging.getLogger()
|
||||
log.info("照片审核开始")
|
||||
main()
|
||||
|
||||
# 崩溃后的重试次数
|
||||
retry_time = 2
|
||||
for _ in range(++retry_time):
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
log.error(traceback.format_exc())
|
||||
send_an_error_email(program_name='照片审核关键信息抽取脚本', error_name=repr(e), error_detail=traceback.format_exc())
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user