b3eeb617 by 周伟奇

add pool_pre_ping

1 parent 39c5df53
......@@ -191,22 +191,23 @@ class Command(BaseCommand, LoggerMixin):
start = i + 1
return img_il_list
def handle(self, *args, **kwargs): # TODO 调用接口重试
sleep_second = 5
max_sleep_second = 60
# TODO 细化文件状态,不同异常状态采取不同的处理
# TODO 调用接口重试
def handle(self, *args, **kwargs):
sleep_second = conf.SLEEP_SECOND
while self.switch:
# 从队列获取文件信息
# 1. 从队列获取文件信息
doc_info, doc_class, doc_id, business_type = self.get_doc_info()
# 从EDMS获取PDF文件
# 2. 从EDMS获取PDF文件
doc_data_path, excel_path, pdf_path = self.pdf_download(doc_id, doc_info, business_type)
# 队列为空时的处理
if pdf_path is None:
time.sleep(sleep_second)
sleep_second = min(max_sleep_second, sleep_second+5)
sleep_second = min(conf.MAX_SLEEP_SECOND, sleep_second+5)
continue
sleep_second = 5
sleep_second = conf.SLEEP_SECOND
try:
# PDF文件提取图片
# 3.PDF文件提取图片
img_save_path = os.path.join(doc_data_path, 'img')
os.makedirs(img_save_path, exist_ok=True)
img_path_list = []
......@@ -274,7 +275,7 @@ class Command(BaseCommand, LoggerMixin):
self.cronjob_log.info('{0} [pdf to img success] [doc_id={1}]'.format(self.log_base, doc_id))
write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id)))
# 图片调用算法判断是否为银行流水, 图片调用算法OCR为excel文件
# 4.图片调用算法判断是否为银行流水, 图片调用算法OCR为excel文件
wb = xlwt.Workbook()
loop = asyncio.get_event_loop()
tasks = [self.img_ocr_excel(wb, img_path) for img_path in img_path_list]
......@@ -282,7 +283,7 @@ class Command(BaseCommand, LoggerMixin):
# loop.close()
wb.save(excel_path) # TODO no sheet (res always [])
# 整合excel文件
# 上传至EDMS
# 5.上传至EDMS
except Exception as e:
doc_class.objects.filter(id=doc_id).update(status=DocStatus.PROCESS_FAILED.value)
self.cronjob_log.error('{0} [process failed] [doc_id={1}] [err={2}]'.format(self.log_base, doc_id, e))
......
from zeep import Client
from zeep.transports import Transport
from requests.auth import HTTPBasicAuth
from requests import Session
# session = Session()
# session.auth = HTTPBasicAuth('qqedms3', 'azhkilc6')
wsdl_path = '/Users/clay/Desktop/biz/biz_logic/data/sessionmanager.wsdl'
client = Client(wsdl=wsdl_path)
# client = Client(wsdl=wsdl_path, transport=Transport(session=session))
with client.settings(raw_response=True):
# res = client.service.StartSessionForDomainUser(login='qqedms3',
# password='azhkilc6',
# domain='960c2a5a-869c-45bd-aca8-de396b684f59',
# clientType='CustomClient')
# res = client.service.StartSession(login='qqedms3', password='azhkilc6', clientType='CustomClient')
# res = client.service.StartSession(login='OCRUAT', password='1qaz2wsx', clientType='CustomClient')
res = client.service.GetSessionInfo(sessionId='40f9e3c1-e6cb-4b22-83b0-0b54433bec42')
print(res)
print(res.status_code)
print(res.content)
# client = Client('http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL')
#
# res = client.service.getMobileCodeInfo(mobileCode='15388058517')
# print(res)
[settings]
DEBUG = False
\ No newline at end of file
DEBUG = False
SLEEP_SECOND = 5
MAX_SLEEP_SECOND = 60
\ No newline at end of file
......
[settings]
DEBUG = True
\ No newline at end of file
DEBUG = True
SLEEP_SECOND = 5
MAX_SLEEP_SECOND = 60
......
[settings]
DEBUG = False
\ No newline at end of file
DEBUG = False
SLEEP_SECOND = 5
MAX_SLEEP_SECOND = 60
......
......@@ -19,6 +19,7 @@ MYSQLPOOL_ARGUMENTS = {
'max_overflow': 10,
'timeout': 5,
'use_threadlocal': True,
'pool_pre_ping': True,
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!