b3eeb617 by 周伟奇

add pool_pre_ping

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