Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c9ac407f
authored
2025-01-10 14:06:31 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
MOD:thread pool
1 parent
5451ebf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
src/celery_compare/tasks.py
src/celery_compare/tasks.py
View file @
c9ac407
...
...
@@ -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]'
...
...
@@ -3717,13 +3720,17 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
@app.task
def
fsm_compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
# try:
#
producer_thread_fsm = threading.Thread(target=fsm_compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
#
producer_thread_fsm = threading.Thread(target=fsm_compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
# 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
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment