优化错误日志及重试机制
This commit is contained in:
@@ -7,8 +7,7 @@ from sqlalchemy import update, and_
|
||||
|
||||
from db import MysqlSession
|
||||
from db.mysql import ZxPhrec, ZxPhhd
|
||||
from photo_mask import OCR, PHHD_BATCH_SIZE, SLEEP_MINUTES, COPY_TRY_TIMES, UPLOAD_TRY_TIMES, NAME_KEYS, \
|
||||
ID_CARD_NUM_KEYS
|
||||
from photo_mask import OCR, PHHD_BATCH_SIZE, SLEEP_MINUTES, NAME_KEYS, ID_CARD_NUM_KEYS
|
||||
from ucloud import BUCKET, ufile
|
||||
from util import image_util, util
|
||||
|
||||
@@ -177,18 +176,12 @@ def photo_mask(pk_phhd, name, id_card_num):
|
||||
|
||||
# 如果涂抹了要备份以及更新
|
||||
if is_masked:
|
||||
for i in range(COPY_TRY_TIMES):
|
||||
is_copy_success = ufile.copy_file(BUCKET, phrec.cfjaddress, "drg2015", phrec.cfjaddress)
|
||||
if is_copy_success:
|
||||
break
|
||||
ufile.copy_file(BUCKET, phrec.cfjaddress, "drg2015", phrec.cfjaddress)
|
||||
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
||||
cv2.imwrite(temp_file.name, image)
|
||||
try:
|
||||
for i in range(UPLOAD_TRY_TIMES):
|
||||
is_upload_success = ufile.upload_file(phrec.cfjaddress, temp_file.name)
|
||||
if is_upload_success:
|
||||
break
|
||||
ufile.upload_file(phrec.cfjaddress, temp_file.name)
|
||||
except Exception as e:
|
||||
logging.error("上传图片出错", exc_info=e)
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user