c9ac407f by 冯轩

MOD:thread pool

1 parent 5451ebf6
......@@ -52,6 +52,9 @@ from common.tools.des import decode_des
import threading
import concurrent.futures
from concurrent.futures import ThreadPoolExecutor
pool = ThreadPoolExecutor(max_workers=20, thread_name_prefix="my_thread_")
compare_log = logging.getLogger('compare')
log_base = '[Compare]'
......@@ -3721,9 +3724,13 @@ def fsm_compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=
# producer_thread_fsm.start()
# except Exception as e:
# compare_log.info('[fsm thread error] [error={0}]'.format(traceback.format_exc()))
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
# 使用map函数提交多个任务
results = list(executor.map(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
# with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
# # 使用map函数提交多个任务
# results = list(executor.map(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
compare_log.info('[fsm thread]')
pool.submit(fsm_compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)
def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False):
......@@ -3793,9 +3800,13 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
# producer_thread.start()
# except Exception as e:
# compare_log.info('[thread error] [error={0}]'.format(traceback.format_exc()))
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
# 使用map函数提交多个任务
results = list(executor.map(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
# with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
# # 使用map函数提交多个任务
# results = list(executor.map(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
compare_log.info('[non fsm thread]')
pool.submit(compare_thread, application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms)
def compare_thread(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True, is_cms=False):
# POS: application_id, application_entity, uniq_seq, None
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!